Download file from server and manipulate it using C#

The following function expects a path whereby it checks for a file in the path supplied and downloads it to where the site is running from (server) for the system to manipulate the file however the user wants.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;  
public class ClsDownload
    public ClsDownload()
        // TODO: Add constructor logic here
public void download(string filePath)
        if (File.Exists(filePath))
            HttpContext.Current.Response.ContentType = "application/octet-stream";
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(filePath));
   } }

Enjoyed this post? Share it!


Leave a comment

Your email address will not be published.