.net – How to get current working directory path c#?

.net – How to get current working directory path c#?

You can use static Directory class – however current directory is distinct from the original directory, which is the one from which the process was started.


So you can use the following to get the directory path of the application executable:


use Application.StartupPath returns path for the executable file that started the application.

        string pathCur = Path.Combine(Application.StartupPath, @....r.cur);
        Cursor = new Cursor(pathCur);

.net – How to get current working directory path c#?

You can also get by
but it shows bin and debug folder also, if you dont want these folder so you can use that code :

string page = E:abccomCatMouse.aspx

string name = Path.GetFileName(page );
string nameKey = Path.GetFileNameWithoutExtension(page );
string directory = Path.GetDirectoryName(page );

Console.WriteLine({0}, {1}, {2}, {3},
page, name, nameKey, directory);


GetFileName:                                        Mouse.aspx
GetFileNameWithoutExtension:           Mouse
GetDirectoryName:                              E:abccomCat

Happy Coding 🙂

Leave a Reply

Your email address will not be published.