To get the project directory in C#, you can use the AppDomain.CurrentDomain.BaseDirectory
property. This will return the path of the base directory of the current application domain, which should be the project directory.
main.cs65 chars2 lines
You can also use the Directory.GetParent
method to get the parent directory of the current directory, which should be the project directory.
main.cs96 chars2 lines
Note that the second method assumes that the current working directory is set to the project directory. If this is not the case, you may need to adjust the path accordingly.
gistlibby LogSnag