我尝试获取项目的当前目录路径。我试过:
System.IO.Directory.GetDirectoryRoot();
环境.当前目录;
System.IO.Path.GetFullPath(".\");
在所有选项中我得到:
C:\Program Files (x86)\IIS Express\
而不是项目路径。
有没有人有办法解决吗?
我在网上找到了一个链接:Should I use AppDomain.CurrentDomain.BaseDirectory or System.Environment.CurrentDirectory?
你应该使用:string path = AppDomain.CurrentDomain.BaseDirectory ;
事实上,其他值在程序执行期间可能会发生变化。
| 归档时间: |
|
| 查看次数: |
7610 次 |
| 最近记录: |