关于CS程序的更新问题
private void DownloadFile(string URL, string filename, System.Windows.Forms.ProgressBar prog)
{
try
{
System.Net.HttpWebRequest Myrq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
System.Net.HttpWebResponse myrp = (System.Net.HttpWebResponse)Myrq.GetResponse();
long totalBytes = myrp.ContentLength;
if (prog != null)
{
prog.Minimum=0;
prog.Maximum=this.lstvPro.Items.Count;
}
System.IO.Stream st = myrp.GetResponseStream();
System.IO.Stream so = new System.IO.FileStream(filename, System.IO.FileMode.Create);
// System.IO.Stream so = new System.IO.FileStream(filename, System.IO.FileMode.Append);
long totalDownloadedByte = 0;
byte[] by = new byte[1024];
int osize = st.Read(by, 0, (int)by.Length);
while (osize > 0)
{
totalDownloadedByte = osize + totalDownloadedByte;
System.Windows.Forms.Application.DoEvents();
so.Write(by, 0, osize);
osize = st.Read(by, 0, (int)by.Length);
}
if (prog != null)
{
prog.Value++;
}
so.Close();
st.Close();
}
catch (System.Exception)
{
throw;
}
}
现在文件都可以下载下来,但是点更新就报未处理的“System.IO.IOException”类型的异常出现在 Updater.exe 中。
其他信息: 该进程无法访问文件“c:\documents and settings\administrator\桌面\updater\bin\debug\tip1610.exe”,因为该文件正由另一进程使用。
是进程问题吗?求教