Skip to content

How should I get application folder correctly in Linux DRM? #15625

Answered by thevortexcloud
kyuranger asked this question in Q&A
Discussion options

You must be logged in to vote

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.

I saw on the Internet that Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) is used to obtain it, but this method obtains a blank path.

According to Scott Hanselman (a guy who works for Microsoft):

How does it work in .NET Core 5 (> preview 7)? Well, because the assemblies are embedded and loaded from memory in 5, so like any other in…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kyuranger
Comment options

Answer selected by kyuranger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants