How do I find out what directory my console app is running in?

前端 未结 8 844
醉话见心
醉话见心 2020-12-07 12:55

How do I find out what directory my console app is running in with C#?

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 13:42

    In .NET, you can use System.Environment.CurrentDirectory to get the directory from which the process was started.
    System.Reflection.Assembly.GetExecutingAssembly().Location will tell you the location of the currently executing assembly (that's only interesting if the currently executing assembly is loaded from somewhere different than the location of the assembly where the process started).

提交回复
热议问题