2012-10-28 107 views

回答

0

使用此代碼圖片字節流保存到IS:

  using (IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream(tempJPEG, FileMode.Create, myIsolatedStorage)) 
      { 
       using (BinaryWriter writer = new BinaryWriter(fileStream)) 
       { 
        Stream resourceStream = new MemoryStream(imageData); //Byte[] imageData 
        long length = resourceStream.Length; 
        byte[] buffer = new byte[32]; 
        int readCount = 0; 

        using (resourceStream) 
        { 
         resourceStream.Seek(0, SeekOrigin.Begin); 

         // Read file in chunks in order to reduce memory consumption and increase performance 
         while (readCount < length) 
         { 
          int actual = resourceStream.Read(buffer, 0, buffer.Length); 
          readCount += actual; 
          writer.Write(buffer, 0, actual); 
         } 
        } 
       } 

       fileStream.Close(); 
      } 
相關問題