首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Windows上显示.net maui应用程序的PDF

如何在Windows上显示.net maui应用程序的PDF
EN

Stack Overflow用户
提问于 2022-10-11 00:35:32
回答 1查看 152关注 0票数 0

我只是试图显示一个PDF文件,从我的.NET毛伊应用程序在Windows上,这是给我以下错误。

"System.ComponentModel.Win32Exception:‘试图使用工作目录’C:\WINDOWS\system32 32‘启动进程'C:\Users\Documents\helpfile.pdf’时出错。指定的可执行文件对此操作系统平台不是有效的应用程序。“

我的密码在下面。它在WPF应用程序中工作过,但在这里不起作用。

代码语言:javascript
复制
        Process.Start("C:\\Users\\<username>\\Documents\\helpfile.pdf"); // removed the username here and above in error message

也尝试过:(从安装目录获取helpfile.pdf )

代码语言:javascript
复制
        string _asmPath = Assembly.GetExecutingAssembly().Location;

        int lastIndex = _asmPath.LastIndexOf('\\');
        string helpfilePath = $"{_asmPath.Substring(0, lastIndex)}\\helpfile.pdf";

        ProcessStartInfo startInfo = new ProcessStartInfo(helpfilePath);
        Process.Start(startInfo);

我也得到了一个类似的错误:"System.ComponentModel.Win32Exception:‘一个错误发生了,试图用工作目录’C:\WINDOWS\system32 32‘启动进程System.ComponentModel.Win32Exception。指定的可执行文件对于这个操作系统平台来说不是一个有效的应用程序。“

如何在helpfile.pdf上的毛伊岛应用程序中打开这个PDF文档( Win10 )?

谢谢你的帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-11 00:56:09

使用启动器

代码语言:javascript
复制
await Launcher.Default.OpenAsync(new OpenFileRequest("Some Title", new ReadOnlyFile(filepath)));
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74021836

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档