farshad Posted July 23, 2003 Posted July 23, 2003 Hi everyone. My webclient code works fine for downloading a single file from a website. But now I would like to download two or as many as there are files on the website. This gives an error as follows, although it still downloads the second file too.?: The error is: An unhandled exception of type 'system.net.webexception occured in system.dll' 'Additional information: The remote server returned an error (404) not found' Thank you Quote Farshad
*Experts* mutant Posted July 23, 2003 *Experts* Posted July 23, 2003 What is your code? What lines is the error on? Quote
farshad Posted July 23, 2003 Author Posted July 23, 2003 This is the code. Dim strURL As String = "http://www.test.com/images/" Dim strFileName1 As String = "pic1.gif" Dim strFileName2 As String = "pic2.JPG" Dim strFullPath1 As String = Nothing Dim strFullPath2 As String = Nothing Dim wc As New WebClient strFullPath1 = strURL + strFileName1 strFullPath2 = strURL + strFileName2 wc.DownloadFile(strFullPath1, strFileName1) wc.DownloadFile(strFullPath2, strFileName2) Quote Farshad
Leaders dynamic_sysop Posted July 23, 2003 Leaders Posted July 23, 2003 try this : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim client(1) As Net.WebClient Dim strUrls() As String = {"http://www.xtremedotnettalk.com/images/blue/on.gif", "http://www.xtremedotnettalk.com/images/smilies/mad.gif"} Dim strPath() As String = {"D:\im1.gif", "D:\im2.gif"} Dim x As Integer For x = 0 To 1 client(x) = New Net.WebClient() client(x).DownloadFile(strUrls(x), strPath(x)) client(x).Dispose() Next End Sub Quote
*Experts* mutant Posted July 23, 2003 *Experts* Posted July 23, 2003 I tried your code, none of those two imaes exist on the server. Tried downloading and viewing in browser. Thats why the error. Maybe you should look for some other website with images for testing Quote
farshad Posted July 23, 2003 Author Posted July 23, 2003 download With the help of someone on this site I have managed to download specific files from a web site and save them on the local machine. But now I would like to loop through the folder in the website and one by one collectthe files and on each loop upload the files Thanks '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' This bit of code downloads specific files from a website to the local machine Dim strURL As String = "http://www.test.com/images/" Dim strFileName() As String = {"image1.jpg", "image2.gif"} Dim strFullPath As String Dim wc(1) As WebClient For i As Integer = 0 To 1 wc(i) = New WebClient strFullPath = strURL & strFileName(i) wc(i).DownloadFile(strFullPath, "C:\Farshad\Net\VB\Windows\" & strFileName(i)) wc(i).Dispose() Next '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' This bit of code gets all the files in a folder on the local machine... Dim d() As String d = System.IO.Directory.GetFiles("C:\Farshad\Net\VB\Files\") Dim en As System.Collections.IEnumerator en = d.GetEnumerator While en.MoveNext Console.WriteLine(CStr(en.Current)) End While '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Quote Farshad
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.