void GetFile(string URL, string destPath) { if (string.IsNullOrEmpty(URL)) throw new ArgumentNullException("URL"); if (string.IsNullOrEmpty(destPath)) throw new ArgumentNullException("destPath"); WebRequest request = WebRequest.Create(URL); WebProxy proxy = WebProxy.GetDefaultProxy(); proxy.UseDefaultCredentials = true; request.Proxy = proxy; using (Stream stream = request.GetResponse().GetResponseStream()) { using (StreamReader reader = new StreamReader(stream)) { File.WriteAllText(destPath, reader.ReadToEnd()); } } MessageBox.Show("Done downloading the file " + Path.GetFileName(destPath), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)