Talk2Tom11 Posted September 26, 2004 Posted September 26, 2004 Hey I wrote this code: Imports System.Net Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim wClient As New WebClient 'address of file to download Dim UpdateFile As String = "http://sitewithfile/1.txt" 'download file and folder to put it wClient.DownloadFile(UpdateFile, "C:\1.txt") End Sub and when I run the program and click button 1 it gives me and error on this line: wClient.DownloadFile(UpdateFile, "C:\1.txt") If anyone knows what I did wrong please post Quote
Administrators PlausiblyDamp Posted September 26, 2004 Administrators Posted September 26, 2004 Any chance of a clue as to what the error was? It is a lot easier for people to help if you give them more information. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Talk2Tom11 Posted September 26, 2004 Author Posted September 26, 2004 sorry... this was the error: An unhandled exception of type 'System.Net.WebException' occurred in system.dll Additional information: An exception occurred during a WebClient request. Quote
Administrators PlausiblyDamp Posted September 26, 2004 Administrators Posted September 26, 2004 Does the file 1.txt already exist? IIRC i think you need to specify a file that doesn't already exist. If not you may want to check if the file is in use and as such prevented from being over-written. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Talk2Tom11 Posted September 26, 2004 Author Posted September 26, 2004 there is no C:/1.txt file that exist to begin with Quote
Talk2Tom11 Posted September 26, 2004 Author Posted September 26, 2004 the code works when I download something from a website... but I am trying to download from an ftp... maybe that is the difference... I am addressing it like this... ftp://Username:Password@IPAddress/1.txt when i type that in IE it prompts me to download the file... so I don't understand why I doesn't work here. Quote
Administrators PlausiblyDamp Posted September 26, 2004 Administrators Posted September 26, 2004 The web client only supports Http / https and not ftp. If you have a search in these forums you will find a couple of examples of downloading via ftp. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
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.