How can I get the application's path in a .NET console application?

后端 未结 27 1441
甜味超标
甜味超标 2020-11-21 11:11

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 d

27条回答
  •  灰色年华
    2020-11-21 11:48

    For Console Applications, you can try this:

    System.IO.Directory.GetCurrentDirectory();
    

    Output (on my local machine):

    c:\users\xxxxxxx\documents\visual studio 2012\Projects\ImageHandler\GetDir\bin\Debug

    Or you can try (there's an additional backslash in the end):

    AppDomain.CurrentDomain.BaseDirectory
    

    Output:

    c:\users\xxxxxxx\documents\visual studio 2012\Projects\ImageHandler\GetDir\bin\Debug\

提交回复
热议问题