C#将未知文件下载到特定路径并更改扩展名
正在尝试将文件下载到特定路径,并重命名扩展名C#将未知文件下载到特定路径并更改扩展名,c#,C#,正在尝试将文件下载到特定路径,并重命名扩展名 using (var client = new WebClient()) { string newid = Convert.ToString(id); string file = client.DownloadFile("https://www.roblox.com/asset/?id=" + newid); Path.ChangeExtension(file, ".png"); } 我尝试了一些解决方案,但没有找到更多的解决
using (var client = new WebClient())
{
string newid = Convert.ToString(id);
string file = client.DownloadFile("https://www.roblox.com/asset/?id=" + newid);
Path.ChangeExtension(file, ".png");
}
我尝试了一些解决方案,但没有找到更多的解决方案。来自:
参数
地址类型:System.String要从中下载数据的URI
文件名类型:系统。字符串要创建的本地文件的名称
接收数据
因此,您的代码应该如下所示:
using (WebClient client = new WebClient())
{
String newid = id.ToString();
String uri = "https://www.roblox.com/asset/?id=" + newid;
String path = @"C:\MyFolder\Asset_" + newid + ".png";
client.DownloadFile(uri, path);
}
它不起作用
你的帖子也不起作用。阅读并采取行动
using (WebClient client = new WebClient())
{
String newid = id.ToString();
String uri = "https://www.roblox.com/asset/?id=" + newid;
String path = @"C:\MyFolder\Asset_" + newid + ".png";
client.DownloadFile(uri, path);
}