C#文件下载,保存在本地,根据文件地址或网络地址

代码

//下载的文件地址
string filePath = "D:\Web\File\8CB4CF1E-4B0A-DA05-B0AC-76F43AF340A7.pdf";
//保存的文件地址
string fileName ="D:\Web\ExportFile\8CB4CF1E-4B0A-DA05-B0AC-76F43AF340A7.pdf";
using (System.Net.WebClient client = new System.Net.WebClient())
{
    
    
	client.Credentials = System.Net.CredentialCache.DefaultCredentials;
	client.DownloadFile(filePath, fileName);
}

猜你喜欢

转载自blog.csdn.net/vaecnfeilong/article/details/129000423