dpan
Active member
- Joined
- Nov 22, 2005
- Messages
- 28
- Programming Experience
- Beginner
I am having a problem and I do not know why. I am tring to download a file while adding download progress to my progress bar. It works fine for most files, however if I try to download a file with a .php extention I get an error.
Here is the code:
her is my error:
any idea why this giving an error....
Here is the code:
VB.NET:
Dim request As WebRequest
Dim response As WebResponse
Dim reader As Stream
Dim writer As Stream
Dim data(10) As Byte
Dim count As Integer
Dim total As Integer
Me.Show()
Me.Text = "Downloading file ....."
Application.DoEvents()
request = WebRequest.Create("http://www.magoffin.k12.ky.us/docidregistration.php")
response = request.GetResponse()
reader = response.GetResponseStream()
ProgressBar1.Maximum = CInt(response.ContentLength)
ProgressBar1.Value = 0
total = 0
writer = File.Create("test.htm")
While True
count = reader.Read(data, 0, 11)
If count <= 0 Then
Exit While
End If
writer.Write(data, 0, count)
total += 11
If total < ProgressBar1.Maximum Then ProgressBar1.Value = total
Application.DoEvents()
End While
reader.Close()
writer.Close()
Application.DoEvents()
Me.Text = "all done"
her is my error:
VB.NET:
System.ArgumentOutOfRangeException was unhandled
Message="Value of '-1' is not valid for 'Maximum'. 'Maximum' must be greater than or equal to 0.
Parameter name: Maximum"..................
any idea why this giving an error....