Example #1
0
 public static void DownloadFile(int id, string path)
 {
     using (TestASPEntities db = new TestASPEntities())
     {
         var file = db.Files.FirstOrDefault(f => f.Id == id);
         using (DocX Document = DocX.Load(new MemoryStream(file.File1)))
         {
             Document.SaveAs(path);
         }
     }
 }
Example #2
0
        public static void UploadFile(string name, string path)
        {
            using (DocX Document = DocX.Load(path))
            {
                MemoryStream ms = new MemoryStream();
                Document.SaveAs(ms);

                using (TestASPEntities db = new TestASPEntities())
                {
                    File file = new File
                    {
                        Name  = name,
                        File1 = ms.ToArray()
                    };
                    db.Files.Add(file);
                    db.SaveChanges();
                }
            }
        }