Hi,
I am building a VB.NET application in which i need to automatically read a file's contents whose link exists on a web page for a third party web site.The link url for the file looks like this:
http://
When i paste the url directly on the browser it gives a file download box (open/save).but i need to do the download through backend, using a code like this:
Dim sr As StreamReader
Dim txt As String
Dim streamWriter As System.IO.StreamWriter
Dim sw As StreamWriter
Dim wReq As HttpWebRequest
Dim exFolder As String
// strURL is the file url mentioned above
.Proxy = WebRequest.DefaultWebProxy
.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials
.Credentials =
.CookieContainer = cookieJar
.UserAgent = "BGClient"
'.UseBinary = True
.KeepAlive = True
.Headers.Set("Pragma", "no-cache")
'.Timeout = 1000000000
'.Method = System.Net.WebRequestMethods.Ftp.DownloadFile '"POST"
.ContentType = "application/msword"
'.ReadWriteTimeout = 1000000000
.PreAuthenticate = True End With
wResp = wReq.GetResponse
sr = New StreamReader(wResp.GetResponseStream)
txt = sr.ReadToEnd.Trim
sr.Close()
wResp.Close()
wReq = Nothing
If
Not txt Is Nothing And txt.Length > 0 ThenstreamWriter =
New StreamWriter(dFolder & strTitle & "." & fType, False)streamWriter.WriteLine(txt)
streamWriter.Close()
streamWriter = Nothing
fCount = fCount + 1
End If
I have tried using web client and also FTPwebrequest, but the site does not accept ftp requests.
Please help.Thanks in advance!!

Answers
Know the answer? Post it. Somebody with the same question will find it here.