【发布时间】:2012-10-25 04:46:21
【问题描述】:
所以我有一个文件(例如 index.html),我想获取它的路径。 我的大部分文件都存储在 debug- 文件夹中。 所以例如我想得到路径:
C:\documents and settings\administrator\My Documents\Visual Studio 2010\Projects\WebServer\WebServer\bin\Debug\index.html
我已经尝试过 Path.GetDirectoryname(filename); //不起作用,因为我没有得到任何回报
【问题讨论】:
-
您想在所有硬盘驱动器/网络文件夹中搜索所有文件名 index.html,还是在某处引用它?或者你只想在你的exe运行的文件夹中搜索?
-
string path = Application.StartupPath + "\\index.html"; -
吴宇森的回答对我有用,感谢您的快速回答!