使用WebClient+backGroundWork下载http文件时的问题,再线等,解答马上给分
private Stream m_webFileStream;
private void bakDownFile_DoWork(object sender, DoWorkEventArgs e)
{
try
{
String url = (String)e.Argument;
WebClient web = new WebClient();
m_webFileStream = web.OpenRead(url);
}
catch (WebException)
{
MessageBox.Show("Test");
m_isSuccessDownFilr = false;
}
finally
{
GC.Collect();
if (m_webFileStream != null
&& m_downFile != null)
{
m_webFileStream.Close();
m_webFileStream = null;
m_downFile.Close();
m_downFile = null;
}
}
}
就是第二次执行m_webFileStream = web.OpenRead(url);一定会抛出异常
强制垃圾收集,强制web.Dispoad()也不行

