Catching Error from Download File

Cheetah

Well-known member
Joined
Oct 12, 2006
Messages
232
Programming Experience
Beginner
Hi there,

I have the following line of code to download a file from the net (they are not variables in there, its just to show what would go in there):

VB.NET:
My.Computer.Network.DownloadFile(httpaddress,detstinationtodownload,username,password,showui?,connectiontimeout,overwrite?)

How would i catch the error when the connection has timed out?

Thanks.
 
TimeoutException is thrown, which you can Try-Catch:
VB.NET:
[SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]  My[/COLOR][/SIZE][SIZE=2].Computer.Network.DownloadFile(.........)
[/SIZE][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] TimeoutException[/SIZE]
[SIZE=2]  '....
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE]
Documentation for My.Computer.Network.DownloadFile Method specifies the different exceptions that may occur for this method.
 
Back
Top