示例#1
0
 public void SaveFiles(IEnumerable <HttpPostedFileBase> files, Project project)
 {
     foreach (HttpPostedFileBase item in files)
     {
         if (item != null)
         {
             string   prefix = Guid.NewGuid().ToString() + item.FileName;
             FilesCRM file   = new FilesCRM()
             {
                 Name = prefix, FileName = item.FileName
             };
             project.FilesCRMs.Add(file);
             item.SaveAs(Server.MapPath("~/Files/" + prefix));
         }
     }
 }
 public void SaveFiles(HttpFileCollectionBase files, TaskOfProject task)
 {
     foreach (string file in files)
     {
         HttpPostedFileBase item = Request.Files[file];
         if (item != null && item.ContentLength > 0)
         {
             string   prefix   = Guid.NewGuid().ToString() + item.FileName;
             FilesCRM fileSave = new FilesCRM()
             {
                 Name = prefix, FileName = item.FileName
             };
             task.FilesCRMs.Add(fileSave);
             item.SaveAs(Server.MapPath("~/Files/" + prefix));
         }
     }
 }