My app's local storage stored some MS office files, how can open and show them from my app?

有帮助吗?

解决方案

If your app just downloaded a file and it went into the storage folder, you can use Launcher class to launch an app from the phone which can open the downloaded file for you.

Class StorageFolder will help you get your StorageFile. Considering you already have an object of kind StorageFile, you can use the following line to launch a suitable app automatically from your phone ::

      await Launcher.LaunchFileAsync(storageFile);

This will open the app associated with the file type. I hope i got your question clearly and answered in the right direction. Thanks.

其他提示

Hopefully, the code is similar to selecting a photo. If it is, then consider the following snippet:

        FileOpenPicker openPicker = new FileOpenPicker();
        openPicker.ViewMode = PickerViewMode.Thumbnail;
        openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
        openPicker.FileTypeFilter.Add(".doc");
        openPicker.FileTypeFilter.Add(".docx");

        // Launch file open picker and caller app is suspended and may be terminated if required
        openPicker.PickSingleFileAndContinue();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top