2017-06-16 21 views
0

私は画像と行に保存しようとしていますbitmapImg.Compress(Bitmap.CompressFormat.Png、90、fos);はエラーを表示し、Java.IO.FileOutputStreamをSystem.IO.Streamに変換できません。どのようにそれを解決するには?あなたはJavaの名前空間からクラスを通過する間Java.IO.FileOutputStreamをSystem.IO.Streamに変換できません。

File file = new File(Android.OS.Environment.DirectoryPictures + File.Separator + "newProdict.png"); 
      FileOutputStream fos = null; 
      try 
      { 
       fos = new FileOutputStream(file); 
       if (fos != null) 
       { 
        bitmapImg.Compress(Bitmap.CompressFormat.Png, 90, fos); 
        fos.Close(); 
       } 
      } 
      catch (Exception ex) { } 
+0

ビットマップ画像I」でありますスマートフォンのギャラリーに保存しようとしています。 C# –

+1

私はFileOutputStreamの代わりにFileStreamを使うべきだと信じます –

+0

私の答えのパスを編集しました –

答えて

1

圧縮機能は、.NET System.IO.Streamから派生何かを期待し、代わりのFileStreamを使用します。

try 
    { 

    string path = Path.Combine(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures).AbsolutePath, "newProdict.png"); 
    var fs = new FileStream(path, FileMode.Open); 
     if (fs != null) 
     { 
      bitmapImg.Compress(Bitmap.CompressFormat.Png, 90, fs); 
      fos.Close(); 
     } 
    } 
    catch (Exception ex) { } 
+0

"/Pictures/newProdict.png"の部分を見つけることができませんでした –

+0

素晴らしいです。この質問に対する回答をお手伝いできる場合は、[link](https://stackoverflow.com/questions/44584067/how-to-get-the-path-to-the-internal-memory-of-the-smartphone- and-the-dcim-folder) –

+0

@ 'FileMode.OpenOrCreate'を試してみてください – Pierre

関連する問題