简体   繁体   English

MSIX WPF - Package.InstalledLocation 等效项

[英]MSIX WPF - Package.InstalledLocation Equivalent

I've created an Windows Application Packaging Project for a WPF app.我为 WPF 应用程序创建了 Windows 应用程序打包项目。 The app runs fine and works with a ClickOnce installer.该应用程序运行良好,可与 ClickOnce 安装程序一起使用。

I'm running into a problem with MSIX because I'm using an appsetings.json file, which I've set to BuildAction=Content and Copy Always.我在使用 MSIX 时遇到问题,因为我使用的是 appsetings.json 文件,该文件已设置为 BuildAction=Content 并始终复制。 In ClickOnce I can access that file using Directory.GetCurrentDirectory().在 ClickOnce 中,我可以使用 Directory.GetCurrentDirectory() 访问该文件。

However in my MSIX version I keep getting an error telling me that it can't find the file and that it was expecting to see it in "C:\WINDOWS\system32".但是在我的 MSIX 版本中,我不断收到一个错误消息,告诉我它找不到该文件,并且它希望在“C:\WINDOWS\system32”中看到它。

I've opened the MSIX Bundle with WinRar and the appsettings.json is in there.我用 WinRar 打开了 MSIX Bundle,appsettings.json 在那里。

In UWP apps I read that you can get the installed location with Package.Current.InstalledLocation.Path.在 UWP 应用程序中,我读到您可以使用 Package.Current.InstalledLocation.Path 获取安装位置。

Is there an equivilant for WPF apps?? WPF 应用程序是否有等价物?

In a packaged .NET Core desktop app, you should be able to get the path of the content file using the System.AppContext.BaseDirectory property:在打包的 .NET Core 桌面应用程序中,您应该能够使用System.AppContext.BaseDirectory属性获取内容文件的路径:

string absolutePath = System.AppContext.BaseDirectory + "appsetings.json";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过 Visual Studio MSIX 打包将 Package 支持框架添加到 .Netcore 3.1 应用程序 (WPF) - Add Package support framework to a .Netcore 3.1 app (WPF) through Visual Studio MSIX packaging 阅读 msix package appxmanifest 版本 - Read msix package appxmanifest version Package.Current.InstalledLocation.GetFileAsync和StorageFile.CopyAsync无法正常工作 - Package.Current.InstalledLocation.GetFileAsync and StorageFile.CopyAsync not working as expected .net core 3 wpf/winforms(非 MSIX)的安装程序? - Installer for .net core 3 wpf/winforms (non MSIX)? 如何使用 MSIX package 和部署注册表项 - How to package and deploy a registry key with MSIX 如何在 MSIX package 中包含应用程序文件依赖项? - how to include application file dependencies in MSIX package? MSIX package 和调试器在错误的项目中启动 - MSIX package and debugger are starting in the wrong project wp8 Package.Current.InstalledLocation.GetFolderAsync无法获取Assets下的新文件夹 - wp8 Package.Current.InstalledLocation.GetFolderAsync can't get the new folder under Assets 无法在 Windows 2016(内部版本 1607)上安装 MSIX 包 - Unable to install MSIX package on Windows 2016 (build 1607) MSIX 打包的 WPF 应用程序阻止了 windows 的多个实例? - MSIX packaged WPF app that prevent multiple instances of windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM