c#文件下载


 

 

public static string downzip(string url,string sname)
{
try
{
WebClient client = new WebClient();

string URLAddress = url;

string receivePath = System.Windows.Forms.Application.StartupPath + "/temp/" + sname + "/";
if (!Directory.Exists(receivePath))
{
Directory.CreateDirectory(receivePath);
}

client.DownloadFile(URLAddress, receivePath + System.IO.Path.GetFileName(URLAddress));
return receivePath + System.IO.Path.GetFileName(URLAddress);
}
catch (Exception ex)
{
NLogger.Error(sname+"--"+ url + "--下载失败--" +ex.ToString());
return null;
}
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM