T
Tim Frawley
I am using the following code to download files to my Windows CE
device running pocket pc 2003.
Private Function Download(ByVal strSource As String, _
ByVal strDestination As String) As Boolean
Cursor.Current = Cursors.WaitCursor
Application.DoEvents()
Dim request As System.Net.WebRequest
Dim response As HttpWebResponse = Nothing
Dim s As Stream = Nothing
Try
request = WebRequest.Create(strSource)
request.Method = "GET"
' read file content
response = request.GetResponse()
s = response.GetResponseStream()
Dim b() As Byte = New Byte(response.ContentLength) {}
s.Read(b, 0, b.Length)
' save file into local storage
If File.Exists(strDestination) Then
File.Delete(strDestination)
End If
Dim fs As Stream = File.OpenWrite(strDestination)
fs.Write(b, 0, b.Length)
fs.Close()
Catch ex As Exception
MsgBox(ex.Message & vbCrLf & vbCrLf & strSource)
Finally
If Not response Is Nothing Then response.Close()
If Not s Is Nothing Then s.Close()
End Try
Cursor.Current = Cursors.Default
End Function
The download works fine and all however when I download a CAB or EXE
file for use on the device the format is unrecognized by the device
and will not run. The exe doesn't execute and the CAB file displays
the following error:
The file "blah.cab" is not a valid Windows CE Setup file.
Any ideas how I can get this to work?
device running pocket pc 2003.
Private Function Download(ByVal strSource As String, _
ByVal strDestination As String) As Boolean
Cursor.Current = Cursors.WaitCursor
Application.DoEvents()
Dim request As System.Net.WebRequest
Dim response As HttpWebResponse = Nothing
Dim s As Stream = Nothing
Try
request = WebRequest.Create(strSource)
request.Method = "GET"
' read file content
response = request.GetResponse()
s = response.GetResponseStream()
Dim b() As Byte = New Byte(response.ContentLength) {}
s.Read(b, 0, b.Length)
' save file into local storage
If File.Exists(strDestination) Then
File.Delete(strDestination)
End If
Dim fs As Stream = File.OpenWrite(strDestination)
fs.Write(b, 0, b.Length)
fs.Close()
Catch ex As Exception
MsgBox(ex.Message & vbCrLf & vbCrLf & strSource)
Finally
If Not response Is Nothing Then response.Close()
If Not s Is Nothing Then s.Close()
End Try
Cursor.Current = Cursors.Default
End Function
The download works fine and all however when I download a CAB or EXE
file for use on the device the format is unrecognized by the device
and will not run. The exe doesn't execute and the CAB file displays
the following error:
The file "blah.cab" is not a valid Windows CE Setup file.
Any ideas how I can get this to work?