我正在尝试使用 Xamarin Forms 中的默认应用程序打开文档进行编辑。我尝试了以下方法,但它以只读模式打开文件。我想以读写模式打开,以便我可以编辑文档。我怎样才能在 xamarin 形式的 iOS 中做到这一点?
await Launcher.OpenAsync(new OpenFileRequest { File = new ReadOnlyFile(uri) });
您可以尝试 File.OpenRead 和 File.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);
}
希望对你有用。