从流中保存图像并获取文件路径
Save image from stream and get file path
我想将签名板的图像保存在我的设备中,并获取我保存图像的文件路径。我正在使用 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");
}
见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);
}
我想将签名板的图像保存在我的设备中,并获取我保存图像的文件路径。我正在使用 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");
}
见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);
}