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
↧
xamarin form app file not saving
↧