コード例 #1
0
ファイル: ResourceHelper.cs プロジェクト: windygu/asxinyunet
 public static void GetFileInfo(string fileName)
 {
     ResourceInfo model = new ResourceInfo();            
     model.Md5 = MD5Hash(fileName);
     if (ResourceInfo.FindAllByName(ResourceInfo._.Md5, model.Md5, "", 0, 0).Count <1)
     {
         model.PublishingCompany = "暂无";
         FileInfo fi = new FileInfo(fileName);
         model.Keywords = fi.Name;
         model.Author = "暂无";
         model.BigCategory = "暂无分类";
         model.SmallCategory = "暂无分类";
         model.Source = "网络";
         model.ContentIntroduce = "暂无介绍";
         model.Format = fi.Extension.Replace(".", "");
         model.ISBN = string.Empty;
         model.PublishingDate = DateTime.Now;
         model.Remark = string.Empty;
         model.ResourceName = fi.Name;
         model.ResourceScore = 7;
         model.Size = (int)(fi.Length / 1024);//Kb
         model.StorageLocation = fileName.Substring(1, fileName.Length - 1);//只存储相对位置,把盘符去掉               
         model.Insert();
     }
 }