P
PiotrKolodziej
hi
I have a thread that downloades a file.
Problem is : Not all files are beeing downloaded. I observed that only the
small files are beeing downloaded correctly. I also cant download two files
in a row. I got to Exit and run the program again to even start downloading.
The second problem i interprett as iam not closing something ( but don't
know what ). For the first problem i have no idea what is wrong.Here is the
download thread
Maybe someone could help
try
{
HttpWebRequest request = null;
HttpWebResponse response = null;
request = (HttpWebRequest)WebRequest.Create(FullPath);
request.Headers.Clear();
request.ProtocolVersion = HttpVersion.Version11;
response = (HttpWebResponse)request.GetResponse();
FileStream = response.GetResponseStream();
// Download folder must work
file = new BinaryWriter(File.Create(@"d:\\FM\\" +
fileName));
while ((bufferCount = FileStream.Read(buffer, 0, 64000)) > 0
&& !Stop)
{
//MessageBox.Show("STOP is: " + Stop.ToString() + "
BufferCount is: " + bufferCount.ToString());
store += bufferCount;
file.Write(buffer, 0, bufferCount);
}
file.Close();
response.Close();
FileStream.Close();
file.Close();
if (!Stop)
{
NormalExit = true;
exitDelegate myDeleg = new exitDelegate(exitForm);
this.Invoke(myDeleg);
}
}
I have a thread that downloades a file.
Problem is : Not all files are beeing downloaded. I observed that only the
small files are beeing downloaded correctly. I also cant download two files
in a row. I got to Exit and run the program again to even start downloading.
The second problem i interprett as iam not closing something ( but don't
know what ). For the first problem i have no idea what is wrong.Here is the
download thread
Maybe someone could help
try
{
HttpWebRequest request = null;
HttpWebResponse response = null;
request = (HttpWebRequest)WebRequest.Create(FullPath);
request.Headers.Clear();
request.ProtocolVersion = HttpVersion.Version11;
response = (HttpWebResponse)request.GetResponse();
FileStream = response.GetResponseStream();
// Download folder must work
file = new BinaryWriter(File.Create(@"d:\\FM\\" +
fileName));
while ((bufferCount = FileStream.Read(buffer, 0, 64000)) > 0
&& !Stop)
{
//MessageBox.Show("STOP is: " + Stop.ToString() + "
BufferCount is: " + bufferCount.ToString());
store += bufferCount;
file.Write(buffer, 0, bufferCount);
}
file.Close();
response.Close();
FileStream.Close();
file.Close();
if (!Stop)
{
NormalExit = true;
exitDelegate myDeleg = new exitDelegate(exitForm);
this.Invoke(myDeleg);
}
}