开发者

How to deliver bitmap to the server?

Writing my first silverlight application.

I need to deliver some bitmap that the customer will choose ( used OpenFileDialog ) to the server side ( using web service ).

After the customer choosing the bitmap - i cant access the file and break hit to byte array because i dont see the file full path on the OpenFileDialog object properti开发者_StackOverflowes.

How can i do it ?

( i have method that get Bitmap and return the bitmap as byte array )


I did that before, here is part of it:

OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "Images (*.png; *.jpg)| *.png; *.jpg";
dialog.Multiselect = false;
if (dialog.ShowDialog() == true)
{
  using (System.IO.Stream stream = dialog.File.OpenRead())
  {
    BinaryReader binaryReader = new BinaryReader(stream);
    // here are the bytes you want, put them somewhere to send them to the server
    byte[] imageBytes = binaryReader.ReadBytes((int)stream.Length);

    // here is the filename if you need it
    string filename = System.IO.Path.GetFileNameWithoutExtension(dialog.File.Name);
    stream.Close();
  }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜