解决方案 »

  1.   

    试试  System.Windows.Forms.StartupPath
    Server.MapPath一般用于WEB
    http://www.cnblogs.com/lzrabbit/articles/2441688.html
      

  2.   

    Environment.CurrentDirectory.ToString();
      

  3.   

    比较通用的方法是
    AppDomain.Current.BasePath
      

  4.   

    public static string GetAssemblyPath()  
    {  
        string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;  
      
        codeBase = codeBase.Substring(8, codeBase.Length - 8);    // 8是 file:// 的长度  
      
        string[] arrSection = codeBase.Split(new char[] { '/' });  
      
        string folderPath = "";  
        for (int i = 0; i < arrSection.Length - 1; i++)  
        {  
            folderPath += arrSection[i] + "/";  
        }  
      
        return folderPath;  
    }  
    利用上面这个函数就可以获取这个函数所在的类依附的dll的物理地址
      

  5.   

    Server是ASP.NET的
    Console的用其他方法