using System.IO;
using System.Web;
namespace Sex
{
    public partial class Sex : System.Web.UI.Page
    {
        protected void MenuDownload(string path)
        {
            FileInfo downloadFile = new FileInfo(path);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", downloadFile.Name));
            HttpContext.Current.Response.AddHeader("Content-Length", downloadFile.Length.ToString());
            HttpContext.Current.Response.ContentType = "application/octet-stream";
            HttpContext.Current.Response.WriteFile(downloadFile.FullName);
            HttpContext.Current.Response.End();
        }
        protected void DownloadFileAsZip(string path)
        {
            /* the following Code uses DotNetZip library
            Response.Clear();
            // no buffering - allows large zip files to download as they are zipped
            Response.BufferOutput = false;
            String ReadmeText = "Dynamic content for a readme file...\n" +
                               DateTime.Now.ToString("G");
            string archiveName = String.Format("archive-{0}.zip",
                                              DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
            Response.ContentType = "application/zip";
            Response.AddHeader("content-disposition", "attachment; filename=" + archiveName);
            using (ZipFile zip = new ZipFile())
            {
                // add a file entry into the zip, using content from a string
                zip.AddFileFromString("Readme.txt", "", ReadmeText);
                // add the set of files to the zip
                zip.AddFiles(filesToInclude, "files");
                // compress and write the output to OutputStream
                zip.Save(Response.OutputStream);
            }
            Response.Close();
             */
        }
    }
}
