c# 进度条的问题 我的程序中遇到一个问题: 根据文件列表下载文件,并要加载和执行其中的DLL文件,整个过程要用进度条来显示程序运行的进度,请问大家有什么好的方法?请帮帮忙,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你先要知道该加载和执行其中的DLL文件的大小,再设计StatuStrip 执行时的速度,(采用TImer控件控制速度) public static void DownFile( string URL, string Filename, ProgressBar Prog ){ 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; Prog.Maximum = (int)totalBytes; System.IO.Stream st = myrp.GetResponseStream(); System.IO.Stream so = new System.IO.FileStream(Filename, System.IO.FileMode.Create); long totalDownloadedByte = 0; byte[] by = new byte[1024]; int osize = st.Read(by, 0, (int)by.Length); while (osize > 0) { totalDownloadedByte = osize + totalDownloadedByte; Application.DoEvents(); so.Write(by, 0, osize); Prog.Value = (int)totalDownloadedByte; osize = st.Read(by, 0, (int)by.Length); } so.Close(); st.Close();} 如何定义一个不包含字符的空定长string字符串变量 datagridview 取值 c# 求一个 remoting 程序 C# 发送邮件 怎么在TabControl控件的tabpage上加个自己画的小图标?(顺便散分!!) C#中复制了一个控件,文件名类名也改了,但还是出现错误,郁闷了,大侠帮忙解决一下啊 WebBrowser关闭网页 看灰机.天上好多灰机..............嘻嘻~~~ 什么是组件,就是*.dll,动态库? VS.Net不能调试? 如何对Session["INT型数据"]与具体数字进行比较? C#怎么样写出这样一个方法?
{
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;
Prog.Maximum = (int)totalBytes;
System.IO.Stream st = myrp.GetResponseStream();
System.IO.Stream so = new System.IO.FileStream(Filename, System.IO.FileMode.Create);
long totalDownloadedByte = 0;
byte[] by = new byte[1024];
int osize = st.Read(by, 0, (int)by.Length);
while (osize > 0)
{
totalDownloadedByte = osize + totalDownloadedByte;
Application.DoEvents();
so.Write(by, 0, osize);
Prog.Value = (int)totalDownloadedByte;
osize = st.Read(by, 0, (int)by.Length);
}
so.Close();
st.Close();
}