How to get current working directory path c#?

后端 未结 7 1056
清歌不尽
清歌不尽 2020-12-15 15:08

I have a cursor file in project. I have given the absolute path in code i.e

F:/r.cur  

the problem is this is hard-coded path And i Want

7条回答
  •  太阳男子
    2020-12-15 15:44

    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.

    System.IO.Directory.GetCurrentDirectory();
    

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

    System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
    

提交回复
热议问题