1

I want to save the image of my signature pad in my device and get the file path where I saved the image. I am using xamarin-controls-signature-pad nuget package to capture my signature. Please see my code below:

Stream sigimage = await Signature.GetImageStreamAsync(SignaturePad.Forms.SignatureImageFormat.Png);

string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), signatureFile);

using (var fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
   await sigimage.CopyToAsync(fileStream);
}

if (File.Exists(fileName))
{
    await DisplayAlert("File", "File exist", "ok");
}
else
{
    await DisplayAlert("File", "File does not exist", "ok");
}

enter image description here

Mihail Duchev
  • 4,691
  • 10
  • 25
  • 32

1 Answers1

2

see File Handling in Xamarin Forms

string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "sig.png");

using (var fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
  {
    image.CopyTo(fileStream);
  }
Jason
  • 86,222
  • 15
  • 131
  • 146
  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/186155/discussion-on-answer-by-jason-save-image-from-stream-and-get-file-path). – Bhargav Rao Jan 04 '19 at 04:59