gpt4 book ai didi

c# - 使用C#打开PDF——Windows 8 Store应用程序

转载 作者:行者123 更新时间:2023-12-02 14:24:33 24 4
gpt4 key购买 nike

我希望当用户单击按钮时能够使用 native Windows 阅读器应用程序打开 PDF。到目前为止,我可以使用以下代码成功打开以 (.PNG) 扩展名结尾的文件。但是,当我让链接打开 (.PDF) 文件时,出现以下错误。

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
}
}
}

最佳答案

当您在项目中添加 PDF 文档时,您必须更改其构建操作。

  • 右键单击 PDF 文档。

  • 点击属性。

  • 构建操作更改为内容

关于c# - 使用C#打开PDF——Windows 8 Store应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16567386/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com