How do I find the application's path in a console application?
In Windows Forms, I can use Application.StartupPath
to find the current path, but this doesn't seem to be available in a console application.
How do I find the application's path in a console application?
In Windows Forms, I can use Application.StartupPath
to find the current path, but this doesn't seem to be available in a console application.
Following line will give you an application path:
Above solution is working properly in following situations:
You can use following code, you will get application full path:
You can create a folder name as Resources within the project using Solution Explorer,then you can paste a file within the Resources.
Will resolve the issue to refer the 3rd party reference files with installation packages.
The answer above was 90% of what I needed, but returned a Uri instead of a regular path for me.
As explained in the MSDN forums post, How to convert URI path to normal filepath?, I used the following:
None of these methods work in special cases like using a symbolic link to the exe, they will return the location of the link not the actual exe.
So can use QueryFullProcessImageName to get around that: