❔ Getting exe path of entry point
I do have a WinUI 3 project and I am unable to retrieve the exe path of my application. That's what I have tried. But I get the dll only.
11 Replies
replace the extension with exe
theyre always in the same folder anyway
I will do that, but is it clean?
i mean its the only option
Path.ChangeExtension(String, String) Method (System.IO)
Changes the extension of a path string.
I think I have found the optimal solution
Environment.GetCommandLineArgs()
returns the file name
Thanks for the help. 🙂
Nice to know that Path has a method for changing the extension. Why did they do that? Isn't it just a wrapper for String.Replace
?Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
it covers edge cases
not necessarily always
https://learn.microsoft.com/en-us/dotnet/api/system.environment.getcommandlineargs?view=net-7.0
The first element is the executable file name
you can alternatively use https://learn.microsoft.com/en-us/dotnet/api/system.environment.processpath?view=net-7.0
Environment.ProcessPath Property (System)
Returns the path of the executable that started the currently executing process. Returns null when the path is not available.
yeah but if you
dotnet YourApp.dll
it will return the path to the dll
actually if you run the exe tooWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.