[英]overwrite a file with webclient downloadfile c#
我在C#中使用Webclient.DownloadFile()保存一些文件。 如果文件已经存在,我想覆盖它。 如果存在,此方法会覆盖文件吗? 到目前为止,它似乎并没有覆盖它。
谢谢
这是一个技巧问题吗?
if (File.Exists(myFile))
{
File.Delete(myFile);
}
using (WebClient client = new WebClient())
{
client.DownloadFileAsync(new Uri("http://test.com/exe.rar"), @"C:\exe.rar");
}
如果再次下载,此代码将覆盖文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.