62,244
社区成员




string oldName = string.Format("{0}.jpg",Guid.NewGuid());
WebClient wc = new WebClient();
wc.DownloadFile("图片路径", oldName);
if (wc.ResponseHeaders != null)
{
string cpString = wc.ResponseHeaders["Content-Disposition"];
if (!string.IsNullOrEmpty(cpString))
{
ContentDisposition contentDisposition = new ContentDisposition(cpString);
string fileName = contentDisposition.FileName;
if (!File.Exists(fileName))
{
File.Move(oldName, fileName);
}
else
{
//
}
}
}
至于其他的比如,你要获取我的头像文件名,那只是字符串处理的事,写个正则就获取到了
[^/]*$