C# 下载远程http文件到本地

System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();

dialog.Description = "请选择保存路径";

if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)

{

string url = q.IpAddress + path;

try

{

using (var client = new System.Net.WebClient())

{

client.DownloadFile(url, dialog.SelectedPath + "\\" + System.IO.Path.GetFileName(path));

}

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "下载异常");

return;

}