RE: URLdownloadToFile
-
Anybody had this problem before. I am trying to download a webpage using the URLDownloadToFileA API decalred in urlmon from VB .net and it is not downloading and the returns long value. I tried to trnslate the error code "underlaying portocol is unknown" Declare Function URLDownloadToFile Lib "urlmon" Alias _ "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _ szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long src as string, dest as string lResult as long src = "http:\\www.msn.com" dest = "c:\images\x.html" lResult = URLDownloadToFile(0, src, dest, 0, 0) but the same code works very well in VB 6.0. I can download pages with out a problem. any help appricated. -Murali
-
Anybody had this problem before. I am trying to download a webpage using the URLDownloadToFileA API decalred in urlmon from VB .net and it is not downloading and the returns long value. I tried to trnslate the error code "underlaying portocol is unknown" Declare Function URLDownloadToFile Lib "urlmon" Alias _ "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _ szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long src as string, dest as string lResult as long src = "http:\\www.msn.com" dest = "c:\images\x.html" lResult = URLDownloadToFile(0, src, dest, 0, 0) but the same code works very well in VB 6.0. I can download pages with out a problem. any help appricated. -Murali
How about using the .NET framework WebRequest and Stream to read the data from the URL, then use a FileStream to write it out to a file? There's and example of the read step on GotDotNet, http://samples.gotdotnet.com/quickstart/howto/doc/WebRequests/clientGET.aspx And as for writing it to a file, the .NET library sample: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemIOFileStreamClassTopic.asp