Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

xamarin form app file not saving

$
0
0

I have created xamarin form app for signpad which capture sign and saving png file to device storage but file is not writing on storage

  var image = await signature.GetImageStreamAsync(SignaturePad.Forms.SignatureImageFormat.Png);//getting png file from here'
  var signatureMemoryStream = image as MemoryStream;
  byte[] data = signatureMemoryStream.ToArray();// convert png to bytes[]
  string fileName = "img.png";
  DependencyService.Get<IFileReadWrite>().WriteData(fileName, data);

I have created DependencyService (Interface) for saving file

  public interface IFileReadWrite
  {
    void WriteData(string fileName, byte[] data);
  }

This is my code to save file using native(app.android)

  public class FileHelper : IFileReadWrite
  {
      public void WriteData(string filename, string data)
     {
      var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
      var filePath = Path.Combine(documentsPath, filename);
      File.WriteAllText(filePath, data);
      }
  }

i already have given permission WRITE_EXTERNAL_STORAGE in mainfest


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>