Example #1
0
        public static void DownloadFile(string path)
        {
            try
            {
                Settings.RelativePath = path = path.Replace(Devider, Path.DirectorySeparatorChar);

                var last = path.Split(Path.DirectorySeparatorChar).Last();

                Settings.RelativePath = path.Substring(0, path.Length - last.Length);

                var folder = new Folder("");
                var file   = new File(last);
                folder.Add(file);

                var fileName = file.Name;
                var data     = file.GetData();

                HttpContext.Current.Response.AddHeader("Content-disposition", "attachment;filename=" + fileName);
                HttpContext.Current.Response.ContentType = "application/octet-stream";
                HttpContext.Current.Response.BinaryWrite(data);

                HttpContext.Current.Response.Flush();
                HttpContext.Current.Response.Close();
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                // ignored
            }
        }
Example #2
0
        private void VisitFile(File file)
        {
            var data = file.GetData();

            // Do something with data
            IsModified = true;

            file.SetData(data);
        }