locked
how to save image to server disk using webservice RRS feed

  • Question

  • User-416741251 posted

    hi

     

    i'm trying to save image to the server disk using webservice, the service get the file name and

    the type (byte[]) and he needed to save it to the server disk.

    he need to convert it to some image format (jpg,bmp etc.) and then to save it.

     

    Wednesday, October 14, 2009 11:15 AM

Answers

  • User-263151482 posted

    You have to pass the path someway, the image class figures out the format and you can save it like this:

    FileStream fs = File.Create("theFile.jpg");
    Image.Save(fs, ImageFormat.Jpeg);
    

    That saves the image to a file called theFile in Jpeg format.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 15, 2009 5:37 AM

All replies

  • User-263151482 posted

    using (MemoryStream ms = new MemoryStream(myByteArray,0,myByteArray.Length))
    {
        ms.Write(myByteArray,0,myByteArray.Length);
        newImage = Image.FromStream(ms,true);
    }


    Wednesday, October 14, 2009 2:03 PM
  • User-416741251 posted

    but what about the format, which format is Image, and how he knows to where (path)

    in the disk to save the image? 

    Thursday, October 15, 2009 4:54 AM
  • User-263151482 posted

    You have to pass the path someway, the image class figures out the format and you can save it like this:

    FileStream fs = File.Create("theFile.jpg");
    Image.Save(fs, ImageFormat.Jpeg);
    

    That saves the image to a file called theFile in Jpeg format.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 15, 2009 5:37 AM