S
Simon Wilkinson via DotNetMonster.com
I've tried for many many hours to figure this out, but have finally
admitted defeat... please help!
I am trying to use HTTPWebRequest/HTTPWebResponse to download a file from a
webserver using the following code, with VB.NET 1.1 (CF):
Try
Dim wr As HttpWebRequest = CType(WebRequest.Create(strWebPath &
"manifest.txt"), HttpWebRequest)
wr.KeepAlive = False
Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
Dim streamResponse As Stream = ws.GetResponseStream()
Dim streamRead As New StreamReader(streamResponse)
strWebVersion = streamRead.ReadToEnd()
Catch ex As System.ArgumentException
MessageBox.Show("Web Error:" + Err.Description)
Catch ex As System.Net.WebException
MessageBox.Show("Web Error:" + Err.Description)
Catch ex As Exception
MessageBox.Show("Web Error:" + Err.Description)
End Try
When I set strWebPath = "http://machinename/foldername/" then I (and
another tester in another location) get an unhandled "managed
ArgumentException" - Argument 'Prompt' cannot be converted to type 'String'.
Oddly, when I set strWebPath = "http://IPaddress/foldername/" then I can
successfully download the file (although the tester in the other location
gets the same error).
If I use MsgBox to step through the code to discover where the error is
(sorry, probably not the best way to do this!), it falls over on the line
that declares and returns the HTTPWebResponse.
The web server (IIS) definitely has read permissions for the relevant
folder (indicated by "foldername"), anonymous access is ticked, the same
error is found using emulator or iPAQ.
Please can someone give me some ideas on what I should try?
admitted defeat... please help!
I am trying to use HTTPWebRequest/HTTPWebResponse to download a file from a
webserver using the following code, with VB.NET 1.1 (CF):
Try
Dim wr As HttpWebRequest = CType(WebRequest.Create(strWebPath &
"manifest.txt"), HttpWebRequest)
wr.KeepAlive = False
Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
Dim streamResponse As Stream = ws.GetResponseStream()
Dim streamRead As New StreamReader(streamResponse)
strWebVersion = streamRead.ReadToEnd()
Catch ex As System.ArgumentException
MessageBox.Show("Web Error:" + Err.Description)
Catch ex As System.Net.WebException
MessageBox.Show("Web Error:" + Err.Description)
Catch ex As Exception
MessageBox.Show("Web Error:" + Err.Description)
End Try
When I set strWebPath = "http://machinename/foldername/" then I (and
another tester in another location) get an unhandled "managed
ArgumentException" - Argument 'Prompt' cannot be converted to type 'String'.
Oddly, when I set strWebPath = "http://IPaddress/foldername/" then I can
successfully download the file (although the tester in the other location
gets the same error).
If I use MsgBox to step through the code to discover where the error is
(sorry, probably not the best way to do this!), it falls over on the line
that declares and returns the HTTPWebResponse.
The web server (IIS) definitely has read permissions for the relevant
folder (indicated by "foldername"), anonymous access is ticked, the same
error is found using emulator or iPAQ.
Please can someone give me some ideas on what I should try?