B
Bsiang
Good day,
I am creating PPC application which can download file from server.
But I get IOEception.
The Same code run no error in Desktop Application. Could you all point me
out ?
I am using .Net Compact Framework 1.0 SP3
Using the Code below :
private bool DownloadFile(string url, string filename)
{
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(url);
httpWebRequest.AllowWriteStreamBuffering = true;
if ( httpWebRequest != null )
{
HttpWebResponse httpWebResponse = (HttpWebResponse)
httpWebRequest.GetResponse();
if ( httpWebResponse != null )
{
Stream httpStream = httpWebResponse.GetResponseStream();
Stream fileStream = File.Create(filename);
if ( httpStream != null && fileStream != null ) ===>
System.IO.IOException happen here
{
byte[] buffer = new byte[1024];
int bytesRead;
do
{
bytesRead = httpStream.Read(buffer, 0, buffer.Length);
fileStream.Write(buffer, 0, bytesRead);
}while (bytesRead > 0);
return true;
}
}
}
return false;
}
Thank you in all advance.
Best regards,
Bsiang.
I am creating PPC application which can download file from server.
But I get IOEception.
The Same code run no error in Desktop Application. Could you all point me
out ?
I am using .Net Compact Framework 1.0 SP3
Using the Code below :
private bool DownloadFile(string url, string filename)
{
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(url);
httpWebRequest.AllowWriteStreamBuffering = true;
if ( httpWebRequest != null )
{
HttpWebResponse httpWebResponse = (HttpWebResponse)
httpWebRequest.GetResponse();
if ( httpWebResponse != null )
{
Stream httpStream = httpWebResponse.GetResponseStream();
Stream fileStream = File.Create(filename);
if ( httpStream != null && fileStream != null ) ===>
System.IO.IOException happen here
{
byte[] buffer = new byte[1024];
int bytesRead;
do
{
bytesRead = httpStream.Read(buffer, 0, buffer.Length);
fileStream.Write(buffer, 0, bytesRead);
}while (bytesRead > 0);
return true;
}
}
}
return false;
}
Thank you in all advance.
Best regards,
Bsiang.