Download Updated File

Pirahnaplant

Well-known member
Joined
Mar 29, 2009
Messages
75
Programming Experience
3-5
I'm currently using this code to download an updated version of a file from the web:
VB.NET:
Dim wc As New WebClient
wc.DownloadFile("weburl", "filename.txt")
The file is already stored in filename.txt and should be overwritten when this code is run.
It usually works, but if I'm not connected to the internet, then it deletes the file then causes an error. So, if I put it in a Try...Catch block, it will still delete the file.

Basically, I need a good way to download a file and overwrite a local file, but do nothing if the file can't be downloaded.

Edit: Oops, I posted this in the wrong forum, could someone move please?
 
Last edited:
(a) use a temporary file, or (b) attempt download the file content and put it in the target file.
 

Latest posts

Back
Top