Вопрос

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