我希望在用戶單擊按鈕時能夠使用本機Windows Reader應用程序打開PDF。到目前爲止,我可以使用以下代碼成功打開以(.PNG)擴展名結尾的文件。但是,當我讓鏈接打開(.PDF)文件時,出現以下錯誤。使用C#打開PDF - Windows 8 Store應用程序
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
文件目的地是正確的。
這裏是我的代碼:
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
}
}
}
在什麼地方發生錯誤?你檢查過這個文件是否真的存在? –
錯誤發生在var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);我通過添加 - >現有項目將pdf添加到文件夾。我可以通過在實際文件夾中雙擊它來打開PDF中的PDF – Dadles