Thursday, June 24, 2010

How to download a image using c# - Asp.net

Download a image we have to set file attachment and content type of the response.
Demo:
Example:
public void DownloadPicture(object sender, EventArgs e)
{
    ImageButton button = sender as ImageButton;
    if (button != null)
    {
        string fileName = button.CommandArgument;
        this.Response.AddHeader(
            "content-disposition"string.Format(
            "attachment;filename={0}"Path.GetFileName(fileName)));
        this.Response.ContentType = "image/jpg";
        this.Response.WriteFile(this.Server.MapPath(fileName));
    }
}

No comments:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...