Launching PDF reader on windows phone 8

后端 未结 3 1428
野性不改
野性不改 2021-01-25 11:54

I\'m trying to launch pdf reader with the code below but it does not work. Can somebody help me?

    private async Task WriteData(string fileN         


        
3条回答
  •  -上瘾入骨i
    2021-01-25 12:38

    LaunchUriAsync isn't supported on Windows Phone 8 per the documentation. It throws an exception if called

    You can use Windows.System.Launcher.LaunchFileAsync to launch a StorageFile.

    This code works for example (assming there's a file called "metro.pdf" in the project, with the Build Action set to Content, with Copy to Output Directory set to Copy if Newer).

    var installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
    var assets = await installedLocation.GetFolderAsync("Assets");
    var pdf = await assets.GetFileAsync("metro.pdf");
    Windows.System.Launcher.LaunchFileAsync(pdf);
    

提交回复
热议问题