Windows8のデフォルトリーダーでファイルを開くボタンをクリックして、winRTアプリ(メトロスタイルアプリ)でpdfファイルを開きたいです。ボタンクリックメソッド名が次のコードを試しましたDefaultLaunch_click()
:
async void DefaultLaunch_click()
{
// Path to the file in the app package to launch
string imageFile = @"images\ret.png";
// Get the image file from the package's image directory
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
if (file != null)
{
// Set the recommended app
var options = new Windows.System.LauncherOptions();
options.PreferredApplicationPackageFamilyName = “Contoso.FileApp_8wknc82po1e”;
options.PreferredApplicationDisplayName = “Contoso File App”;
// Launch the retrieved file pass in the recommended app
// in case the user has no apps installed to handle the file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
if (success)
{
// File launched
}
else
{
// File launch failed
}
}
else
{
// Could not find file
}
}
それは.pngファイルで機能しましたが、.pdfファイルが必要です.1.pngをM.pdfに置き換え(画像フォルダーに含めた後)、M.pdfのビルドコンテンツをEmbedded Resourceに設定し、プログラムを実行しましたが、エラーが表示されましたそれ
**The system cannot find the file specified. (Exception from HRESULT: 0x80070002)**