![](/img/trans.png)
[英]ImapX 2.0.0.18 - Unexpected characters in attachments base64 string
[英]How to open base64 string attachments in Xamarin forms
我想在我的 Xamarin.forms 應用程序上打開一個 base64 字符串附件。 我已經為 pdf 和圖像實現了它。 但我無法為以下類型的視頻、文檔、txt 獲得任何解決方案。
這是我的代碼 pdf 和圖像。 我用syncfusion pdf reader打開了pdf,有沒有什么辦法不用nuget就可以打開呢。請幫幫我
if (ContentType == "pdf")
{
var base64EncodedBytes = System.Convert.FromBase64String(attachmentContent);
PdfAttachement = new MemoryStream(base64EncodedBytes);
}
else if (ContentType=="image")
{
var imageString =attachmentContent;
ImgAttachement = ImageSource.FromStream(() => new MemoryStream(System.Convert.FromBase64String(imageString)));
}
我實現了這樣的視頻實現
public string MediaSource;
private async Task VideoContentConvertion(byte [] decodedString,string fileName)
{
var stream = new MemoryStream(decodedString);
string folder = FileSystem.AppDataDirectory;
string videoFile = Path.Combine(folder,fileName);
if (!File.Exists(videoFile))
{
using (FileStream outputStream = File.Create(videoFile))
{
await stream.CopyToAsync(outputStream);
}
savedFileName = videoFile;
}
MediaSource ="local/"+fileName;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.