简体   繁体   English

如何使用运行我的 Windows App Store 应用程序的 C# 获取当前目录?

[英]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.

相关问题 如何使用XAML / C#向Windows应用商店应用中的控件(框/网格)添加“DropShadow”效果? - How do I add a 'DropShadow' effect to a control (box/grid) in a Windows Store App using XAML/C#? 如何使用Windows Store App C#播放D驱动器中存储的媒体文件 - How do I play a Media File Stored in D drive using Windows Store App C# 如何使用C#截取Unity桌面应用程序当前视图的屏幕截图? - How do I take a screenshot of the current view of my desktop app in Unity using C#? 如何将简单的c#控制台应用程序移植到Windows应用商店(XAML)中? - How do I port a simple c# console app into a Windows Store app (XAML)? 如何从C#桌面应用程序中检索Windows应用商店应用程序的图标? - How do I retrieve a Windows Store app's icon from a C# desktop app? 如何在Visual Studio中使用C#代码从Windows 8.1商店应用程序重新启动Windows设备? - How to restart a windows device from my windows 8.1 store app using c# code in visual studios? 在Windows Store应用程序中使用C#从DatePicker获取日期 - Get date from DatePicker using c# in windows store app 我可以知道我的应用程序是否在Windows RT上使用C#运行吗? - Could I know if my app is running on Windows RT with C#? 如何在C#Web APP中获取当前的Windows登录名? - How to get current Windows Login Name in C# Web APP? C#Active Directory应用程序-如何存储服务帐户凭据? - C# Active Directory App - How do I store service account credentials?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM