string path;
                
if(HttpContext.Current != null)
                    path 
= HttpContext.Current.Server.MapPath("~/communityserver.config");
                
else
                    path 
= Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "communityserver.config";

其中:

Directory.GetCurrentDirectory 方法

获取应用程序的当前工作目录。
得到的路径是这样的形式: c:\aaa 
没有后面的"\"


Path.DirectorySeparatorChar 字段

提供平台特定的字符,该字符用于在反映分层文件系统组织的路径字符串中分隔目录级别。
该字段的值在 Unix 上为斜杠(“/”),在 Windows 和 Macintosh 操作系统上为反斜杠(“\”)。

posted on 2006-03-23 17:11  今夜太冷  阅读(3206)  评论(0)    收藏  举报