S
Steve
Hi,
I'm having problems downloading and saving files from the Internet.
When I run the following code multiple times it grinds to a halt on CE4.1
The first time I call it, it works ok, then it gets really slow, and if I
leave it running it takes minutes to return.
However the same exe running on the desktop is fine, and will download all
files fine.
I have a Nexio S160 connected using Wi-Fi,
Any ideas ?
Cheers,
Steve.
int download_file(string webname,string fname)
{
try
{
Stream str;
System.Net.HttpWebRequest wr;
System.Net.HttpWebResponse ws;
FileStream fstr;
wr=(System.Net.HttpWebRequest)System.Net.WebRequest.Create(webname);
ws=(System.Net.HttpWebResponse)wr.GetResponse();
str=ws.GetResponseStream();
BinaryReader reader=new BinaryReader(str,Encoding.UTF8);
int bytesToRead = (int) inBuf.Length;
int bytesRead = 0;
int n;
while(bytesToRead>0)
{
n=reader.Read(inBuf,0,262144*4);
if(n==0)break;
bytesRead+=n;
bytesToRead-=n;
}
str.Close();
ws.Close();
reader.Close();
fstr = new FileStream(fname, FileMode.OpenOrCreate,FileAccess.Write);
fstr.Write(inBuf, 0, bytesRead);
fstr.Flush();
fstr.Close();
}
catch
{
return(1);
}
return(0);
}
I'm having problems downloading and saving files from the Internet.
When I run the following code multiple times it grinds to a halt on CE4.1
The first time I call it, it works ok, then it gets really slow, and if I
leave it running it takes minutes to return.
However the same exe running on the desktop is fine, and will download all
files fine.
I have a Nexio S160 connected using Wi-Fi,
Any ideas ?
Cheers,
Steve.
int download_file(string webname,string fname)
{
try
{
Stream str;
System.Net.HttpWebRequest wr;
System.Net.HttpWebResponse ws;
FileStream fstr;
wr=(System.Net.HttpWebRequest)System.Net.WebRequest.Create(webname);
ws=(System.Net.HttpWebResponse)wr.GetResponse();
str=ws.GetResponseStream();
BinaryReader reader=new BinaryReader(str,Encoding.UTF8);
int bytesToRead = (int) inBuf.Length;
int bytesRead = 0;
int n;
while(bytesToRead>0)
{
n=reader.Read(inBuf,0,262144*4);
if(n==0)break;
bytesRead+=n;
bytesToRead-=n;
}
str.Close();
ws.Close();
reader.Close();
fstr = new FileStream(fname, FileMode.OpenOrCreate,FileAccess.Write);
fstr.Write(inBuf, 0, bytesRead);
fstr.Flush();
fstr.Close();
}
catch
{
return(1);
}
return(0);
}