标签:files 下载 ring void open isp fst filename close
public void DownFile(string uRLAddress, string localPath, string filename) { WebClient client = new WebClient(); 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 paths = localPath + System.IO.Path.GetFileName(uRLAddress); string path = localPath + filename; FileStream fstr = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write); fstr.Write(mbyte, 0, startmbyte); fstr.Flush(); fstr.Close(); }
标签:files 下载 ring void open isp fst filename close
原文地址:http://www.cnblogs.com/myloveblogs/p/7754656.html