开发者

How can I convert a file and save it on server?

I want to save a file from a request. How can I change the format of an image and how can I ren开发者_StackOverflowame them?

Can anyone show me code to rename and convert the format of an image to PNG and save them on server?


How do you retrieve the file and what format is the file in?

You might be able to load it into a Bitmap and then save it using the Bitmap.Save(String, ImageFormat) method. There you can specify the name of the file as well.


This is actually very easy:

// Load the image.
    System.Drawing.Image image1 = System.Drawing.Image.FromFile(@"C:\test.bmp");

    // Save the image in JPEG format.
    image1.Save(@"C:\test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

    // Save the image in GIF format.
    image1.Save(@"C:\test.gif", System.Drawing.Imaging.ImageFormat.Gif);

    // Save the image in PNG format.
    image1.Save(@"C:\test.png", System.Drawing.Imaging.ImageFormat.Png);  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜