I had validated this.To download SSMS which is more than 500M+
static void Main(string[] args) { string url = "https://go.microsoft.com/fwlink/?linkid=2108895&clcid=0x409"; DownloadBigFile(new Uri(url), "ssms.exe"); } static void DownloadBigFile(Uri url, string outputFilePath) { const int BUFFER_SIZE = 16 * 1024; using (var outputFileStream = File.Create(outputFilePath, BUFFER_SIZE)) { var req = WebRequest.Create(url); using (var response = req.GetResponse()) { using (var responseStream = response.GetResponseStream()) { var buffer = new byte[BUFFER_SIZE]; int bytesRead; do { bytesRead = responseStream.Read(buffer, 0, BUFFER_SIZE); outputFileStream.Write(buffer, 0, bytesRead); } while (bytesRead > 0); } } } }
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/107269.html
標籤:C#
上一篇:漫談值型別和參考型別
下一篇:C# 學習筆記 多型(一)虛方法
