I am working on an iOS app where I need to download a .docx file and then open it in MS Word app if it’s installed. I’m using .Net MAUI and C# for development.
First I’m downloading the document file bytes and saving it to a filePath. Then I’m using Office URI schemes to open the MS Word app and passing the saved filePath, but I encounter an error stating the file cannot be opened. I suspect this might be due to iOS sandboxing feature.
This is the code I’m using currently.
var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var filePath = Path.Combine(documentsPath, filename);
System.IO.File.WriteAllBytes(saveAsFilePath, downloadedFileBytes);
var urlFilePath = HttpUtility.UrlPathEncode(saveAsFilePath);
await Launcher.Default.OpenAsync($"ms-word:ofv|u|{urlFilePath}");
Is there any workaround or a different approach to achieve this?
I’ve checked that the path where the file bytes are saved is correct because I can use the same path to open the .docx file in a webView.