如何在 Xamarin Form iOS 上的默认应用程序中打开文件

问题描述 投票:0回答:1

我正在尝试使用 Xamarin Forms 中的默认应用程序打开文档进行编辑。我尝试了以下方法,但它以只读模式打开文件。我想以读写模式打开,以便我可以编辑文档。我怎样才能在 xamarin 形式的 iOS 中做到这一点?

await Launcher.OpenAsync(new OpenFileRequest { File = new ReadOnlyFile(uri) });

xamarin.forms xamarin.ios
1个回答
0
投票

您可以尝试 File.OpenReadFile.OpenWrite 方法来读取或写入文件。

var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal),"myfile");
using (FileStream fs = File.OpenWrite(path))
{
     Byte[] info = new UTF8Encoding(true).GetBytes("This is to test the OpenWrite method.");
    // Add some information to the file.
    fs.Write(info, 0, info.Length);
 }

希望对你有用。

© www.soinside.com 2019 - 2024. All rights reserved.