Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = -1;
            try
            {
                HttpPostedFile file = Request.Files["uploaded"];

                ZipFile zipFile = ZipFile.Read(file.InputStream);
                StringBuilder zipContent = new StringBuilder();
                foreach (var zipEntry in zipFile.Entries)
                {
                    MemoryStream memoryStream = new MemoryStream();
                    zipEntry.Extract(memoryStream);

                    memoryStream.Position = 0;
                    StreamReader reader = new StreamReader(memoryStream);
                    zipContent.AppendLine(reader.ReadToEnd());
                }

                FileUploadContext db = new FileUploadContext();
                db.Files.Add(new Models.File()
                {
                    Content = zipContent.ToString()
                });
                db.SaveChanges();


                Response.ContentType = "application/json";
                Response.Write("{}");
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
Пример #2
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            FileUploadContext db = new FileUploadContext();

            StringBuilder sb = new StringBuilder();
            foreach (var item in db.Files)
            {
                sb.AppendFormat("{0}. <br/>", item.Id);
                sb.AppendFormat("{0} <br/>", item.Content);
            }

            this.FileOutput = sb.ToString();
        }
Пример #3
0
 public DeleteModel(FileUpload.Models.FileUploadContext context)
 {
     _context = context;
 }
Пример #4
0
 public EditModel(FileUpload.Models.FileUploadContext context)
 {
     _context = context;
 }
Пример #5
0
 public CreateModel(FileUpload.Models.FileUploadContext context)
 {
     _context = context;
 }
Пример #6
0
 public IndexModel(FileUpload.Models.FileUploadContext context)
 {
     _context = context;
 }
Пример #7
0
 public DetailsModel(FileUpload.Models.FileUploadContext context)
 {
     _context = context;
 }