Image file write to Stream


  • Hi. I develope an Windows Store app (C# and XAML) and have a trouble with use this code (below) in Windows Store app. In variable "filePath" is name of image (for example "car.jpg"). I most write image like a stream. So how can I write this code in Windows Store app?

    using (BinaryReader r = new BinaryReader(File.OpenRead(filePath)))request.ContentLength = r.BaseStream.Length;
    using( Stream str = request.GetRequestStream() ) {
    byte[] buffer = new byte[r.BaseStream.Length];
    while( true ) {
    int bytes = r.Read( buffer, 0, buffer.Length );
    if( bytes == 0 ) {break;}
    str.Write( buffer, 0, bytes);

    Wednesday, March 26, 2014 10:10 AM

All replies

  • What are you trying to accomplish with this code?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, March 26, 2014 7:06 PM
  • I will Simplify my problem.. Ho can i use

    String path;

     IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
      IsolatedStorageFileStream file = storage.OpenFile(path, FileMode.Open);

    in Windows Store (Metro application - C#)?

    Friday, March 28, 2014 10:53 AM