#region 根据文件路径获取其大小
/// <summary>
/// 根据文件路径获取其大小
/// </summary>
/// <returns></returns>
public static double GetRemoteHTTPFileSize()
{
long size = 0L;
double a = 0;
try
{
ProductCollocationRelation bll = new ProductCollocationRelation();
List<ProductCollocationRelationInfo> list = bll.GetList();
if (list.Count>0)
{
foreach (var item in list)
{
string url = "http://xx.xx.com/upload/image/" + item.Title;
ProductCollocationRelationInfo pcrinfo = new ProductCollocationRelationInfo();
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
request.Method = "HEAD";
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
size = response.ContentLength;
a = Convert.ToDouble((Convert.ToDouble(size) / 1024 / 1024).ToString("#.0000"));
response.Close();
pcrinfo.FileSize =Convert.ToDecimal(a);
pcrinfo.LastEditTime = DateTime.Now;
pcrinfo.GID = item.GID;
bll.Update(pcrinfo, "FileSize,LastEditTime");
}
}
}
catch
{
size = 0L;
}
return a;
}
#endregion