WebClient (System.Net)

This is derived from the WebRequest abstract base class and is a very simple implementation.
Lets you download any type of file (html, images etc)


The WebClient constructor does not take any arguments




Downloading Data

There are 4 methods you can use to download data

  • OpenRead - returns a stream

  • DownloadData - returns a byte string

  • DownloadFile - saves it to a local file

  • DownloadString - returns a string

There are also asynchronous equivalent methods added in .NET 2.0.




Uploading Data

There are 4 methods you can use to Upload Data


  • OpenWrite -

  • UploadData -

  • UploadFile -

  • UploadValues -

There are also asynchronous equivalent methods added in .NET 2.0.




Dim objStream As System.IO.Stream 
Dim objStreamReader As System.IO.StreamReader
Dim objWebClient As System.Net.WebClient

objWebClient = New System.Net.WebClient
objWebClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
objWebClient.Credentials = New System.Net.NetworkCredential(username, password, domain)

objStream - objWebClient.OpenRead(sURL)
objStreamReader = New System.IO.StreamReader(objStream)





© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext