Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我有一个文件(例如 index.html),我想得到它的路径。我的大部分文件都存储在 debug- 文件夹中。所以例如我想得到路径:
C:\documents and settings\administrator\My Documents\Visual Studio 2010\Projects\WebServer\WebServer\bin\Debug\index.html
我已经尝试过 Path.GetDirectoryname(filename); //不起作用,因为我没有得到任何回报
Path.GetFullPath(fileName);
您可能正在搜索Server.MapPath。
MapPath 方法将指定的相对或虚拟路径映射到服务器上相应的物理目录。
从文件名和预期结果中,我推断出您要求的ASP.NET.
ASP.NET