Dad*_*les 2 c# pdf windows-8 winrt-xaml
我希望能够在用户单击按钮时使用本机Windows Reader应用程序打开PDF.到目前为止,我能够使用以下代码成功打开以(.PNG)扩展名结尾的文件.但是,当我让链接打开(.PDF)文件时,我收到以下错误.
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
Run Code Online (Sandbox Code Playgroud)
文件目的地是正确的.
这是我的代码:
private async void btnLoad_Click(object sender, RoutedEventArgs e)
{
// Path to the file in the app package to launch
string imageFile = @"Data\Healthcare-Flyer.pdf";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
if (success)
{
// File launched
}
else
{
// File launch failed
}
}
else
{
// Could not find file
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2067 次 |
最近记录: |