How should I get application folder correctly in Linux DRM? #15625
-
I want to get the folder of my Avalonia application. My Avalonia application is located in /home/admin/AvaloniaApplication At first, I obtained it through AppDomain.CurrentDomain.BaseDirectory. It can obtain the path normally on Windows, but the path obtained on Linux is always /home/admin/ Then I tried to use AppContext.BaseDirectory, but I also got the incorrect path /home/admin/ I saw on the Internet that Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) is used to obtain it, but this method obtains a blank path. Now I can't think of any better way to solve it. Could you please give me a good suggestion? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Every single one of these returns the same correct path for me: Console.WriteLine(Directory.GetCurrentDirectory());
Console.WriteLine(AppContext.BaseDirectory);
Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); Technically the current directory can change after the app starts, but almost nobody does that in .NET.
According to Scott Hanselman (a guy who works for Microsoft):
Are you sure you are not accidentally launching from the wrong location? Is |
Beta Was this translation helpful? Give feedback.
Every single one of these returns the same correct path for me:
Technically the current directory can change after the app starts, but almost nobody does that in .NET.
According to Scott Hanselman (a guy who works for Microsoft):