[英]How do I get the current directory using C# that my Windows App Store app is running in?
I have an older desktop app that I am trying to get working so that I can get it in the Windows App Store.我有一个较旧的桌面应用程序,我正在尝试使用它,以便我可以在 Windows App Store 中获取它。 When I publish the app, run the installed app from the Start menu, and I call this in C#:
当我发布应用程序时,从“开始”菜单运行已安装的应用程序,并在 C# 中调用它:
Directory.GetCurrentDirectory()
It's returning:它回来了:
C:\\Windows\\system32 C:\\Windows\\system32
When the app is actually located here:当应用程序实际位于此处时:
C:\\Program Files\\WindowsApps\\CompanyLLC.MyApp_2.0.16.0_neutral__7ec99svkv2pe4\\MyApp C:\\Program Files\\WindowsApps\\CompanyLLC.MyApp_2.0.16.0_neutral__7ec99svkv2pe4\\MyApp
When I run the app from the actual location folder manually (by browsing to it and double-clicking the exe), Directory.GetCurrentDirectory()
pulls back the correct location.当我从实际位置文件夹手动运行应用程序(通过浏览到它并双击 exe)时,
Directory.GetCurrentDirectory()
拉回正确的位置。 But when I run the app from the installed location in the Start menu, that's when it doesn't work.但是当我从“开始”菜单中的安装位置运行该应用程序时,它就不起作用了。
How do I fix this?我该如何解决?
Note: I am installing the app for testing via publishing it as a side-loading app before uploading to Microsoft.注意:我正在安装该应用程序进行测试,方法是在上传到 Microsoft 之前将其发布为旁加载应用程序。 It already got denied by them once for running into the same issue.
他们已经因为遇到同样的问题而拒绝了一次。
AppDomain.CurrentDomain.BaseDirectory
工作并且是跨平台的 - 包含在.NET Standard 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.