string url = AppDomain.CurrentDomain.BaseDirectory + _Current.BaoGaoUrl;
string remoteUri = System.IO.Path.GetDirectoryName(url);
string[] splitName = _Current.BaoGaoUrl.Split('.');
string ext = splitName[splitName.Length - 1];
string fileName = _Current.YuAnMingCheng + "." + ext;//System.IO.Path.GetFileName(url);
string myStringWebResource = null;
WebClient myWebClient = new WebClient();
myStringWebResource = url;
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = "请选择下载路径";
string foldPath = "";
if (dialog.ShowDialog() == DialogResult.OK)
{
foldPath = dialog.SelectedPath;
}
if (string.IsNullOrEmpty(foldPath))
{
MessageBox.Show("请选择下载路径");
return;
}
myWebClient.DownloadFile(myStringWebResource, foldPath +"\\"+ fileName);
string fullfile = foldPath +"\\"+ fileName;
if (File.Exists(fullfile))//判断文件是否存在
{
MessageBox.Show("下载成功");
}
else
{
MessageBox.Show("下载失败");
}
winform 下载文件到本地
最新推荐文章于 2023-02-04 11:41:20 发布