C产品在市场上有哪些独特优势?
- 内容介绍
- 文章标签
- 相关推荐
本文共计219个文字,预计阅读时间需要1分钟。
最近整理了WebClient两种方式下载文件的方法,具体如下:
第一种方式:csharpstring URLAddress=http://xiazai.jb51.net;string receivePath=C:\\;client.DownloadFile(URLAddress, receivePath + System.IO.Path.GetFileName(URLAddress));
最近整理了WebClient 两种方式下载文件 ,留作以后查询。
第一种
string URLAddress = @"xiazai.jb51.net"; string receivePath=@"C:\"; client.DownloadFile(URLAddress, receivePath + System.IO.Path.GetFileName(URLAddress));
就OK了。
第二种
Stream str = client.OpenRead(URLAddress); StreamReader reader = new StreamReader(str); byte[] mbyte = new byte[1000000]; int allmybyte = (int)mbyte.Length; int startmbyte = 0; while (allmybyte > 0) { int m = str.Read(mbyte, startmbyte, allmybyte); if (m == 0) break; startmbyte += m; allmybyte -= m; } reader.Dispose(); str.Dispose(); string path = receivePath + System.IO.Path.GetFileName(URLAddress); FileStream fstr = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write); fstr.Write(mbyte, 0, startmbyte); fstr.Flush(); fstr.Close();
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。
本文共计219个文字,预计阅读时间需要1分钟。
最近整理了WebClient两种方式下载文件的方法,具体如下:
第一种方式:csharpstring URLAddress=http://xiazai.jb51.net;string receivePath=C:\\;client.DownloadFile(URLAddress, receivePath + System.IO.Path.GetFileName(URLAddress));
最近整理了WebClient 两种方式下载文件 ,留作以后查询。
第一种
string URLAddress = @"xiazai.jb51.net"; string receivePath=@"C:\"; client.DownloadFile(URLAddress, receivePath + System.IO.Path.GetFileName(URLAddress));
就OK了。
第二种
Stream str = client.OpenRead(URLAddress); StreamReader reader = new StreamReader(str); byte[] mbyte = new byte[1000000]; int allmybyte = (int)mbyte.Length; int startmbyte = 0; while (allmybyte > 0) { int m = str.Read(mbyte, startmbyte, allmybyte); if (m == 0) break; startmbyte += m; allmybyte -= m; } reader.Dispose(); str.Dispose(); string path = receivePath + System.IO.Path.GetFileName(URLAddress); FileStream fstr = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write); fstr.Write(mbyte, 0, startmbyte); fstr.Flush(); fstr.Close();
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。

