【问题标题】:Save image from stream and get file path从流中保存图像并获取文件路径
【发布时间】:2019-01-04 02:20:59
【问题描述】:

我想将签名板的图像保存在我的设备中,并获取我保存图像的文件路径。我正在使用 xamarin-controls-signature-pad nuget 包来捕获我的签名。请参阅下面的代码:

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");
}

【问题讨论】:

    标签: xamarin xamarin.forms stream signaturepad


    【解决方案1】:

    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);
      }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-16
    • 2019-03-28
    • 1970-01-01
    相关资源
    最近更新 更多