我有下载文件的代码,它只是替换了它。
WebClient webClient = new WebClient();
{
webClient.DownloadFile("http://test.png", "C:\PNG.png")
}
我只是想知道,是否可以下载文件,然后保存文件而不是替换旧文件(在上面的示例中,png.png)。
最佳答案
每次都创建一个唯一的名称。
WebClient webClient = new WebClient();
{
webClient.DownloadFile("http://test.png", string.Format("C:\{0}.png", Guid.NewGuid().ToString()))
}
关于c# 使用 WebClient 下载文件并保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33649294/