Thursday, 12 December 2013

Save image from oneLocation to Another Location Using C# Asp.Net

byte[] bitmapdata;
    string strFilePath = "";
    protected void Button1_Click(object sender, EventArgs e)
    {
        string path = @"F:\bhasker\web\";
        strFilePath = path;
        Bitmap bmp = new Bitmap(@"F:\bhasker\web\publish\images.bmp");
        MemoryStream ms = new MemoryStream();
        bmp.Save(ms, ImageFormat.Bmp);
        strFilePath += bmp + ".jpg";
        bitmapdata = ms.ToArray();
        MemoryStream ms1 = new MemoryStream(bitmapdata);
        Bitmap bmp1 = new Bitmap(ms1);
        string realPath = strFilePath;
        System.Drawing.Image img = ResizeImage(bmp1, 75);
        img.Save(Server.MapPath("~/" + realPath));
        Image1.ImageUrl = Convert.ToString(bmp1);
    }

    private System.Drawing.Image ResizeImage(System.Drawing.Image bmp23, int imageWidth)
    {
        System.Drawing.Image image;
        image = bmp23.GetThumbnailImage(imageWidth, 60, null, IntPtr.Zero);
        return image;
    }
    S

No comments:

Post a Comment