gpt4 book ai didi

c# 使用 WebClient 下载文件并保存

转载 作者:太空宇宙 更新时间:2023-11-03 21:16:48 24 4
gpt4 key购买 nike

我有下载文件的代码,它只是替换了它。

    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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com