HttpWebRequest request; HttpWebResponse response = null; string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string pathDownload = Path.Combine(pathUser, "Downloads"); request = (HttpWebRequest)WebRequest.Create(strURL); request.Credentials = System.Net.CredentialCache.DefaultCredentials; request.Timeout = 20000; request.AllowWriteStreamBuffering = true; response = (HttpWebResponse)request.GetResponse(); Stream s = response.GetResponseStream(); if (!Directory.Exists("C:\\Users\\Administrator\\Downloads")) { Directory.CreateDirectory(@"C:\Users\Administrator\Downloads"); } string aFilePath = "C:\\Users\\Administrator\\Downloads" + "\\" + strFileName; FileStream fs = new FileStream(aFilePath, FileMode.Create); byte[] read = new byte[256]; int count = s.Read(read, 0, read.Length); while (count > 0) { fs.Write(read, 0, count); count = s.Read(read, 0, read.Length); } fs.Close(); s.Close(); response.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)