请问:如何获得当前应用程序的路径?如果我做的是类库,用的方法也是一样的吗?
我只知道用System.Environment.SystemDirectory可以得到C:\windows\system32\的路径。

解决方案 »

  1.   

    Environment.CurrentDirectory;
    Application.StartupPath;
    System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;//应用程序的路径和文件名
      

  2.   

    System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
      

  3.   

    得到显示器分辨率 
    Dim X As Short = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
    Dim Y As Short = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
    MsgBox("您的显示器分辨率是:" & X & " X " & Y)得到特殊文件夹的路径 
    '"Desktop"桌面文件夹路径
    MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
    '"Favorites"收藏夹路径
    MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.Favorites))
    '"Application Data"路径
    MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))'通用写法
    'Dim SPEC As String = Environment.GetFolderPath(Environment.SpecialFolder.XXXXXXX)
    'XXXXXXX是特殊文件夹的名字得到操作系统版本信息 
    MsgBox(Environment.OSVersion.ToString)得到当前登录的用户名 
    MsgBox(Environment.UserName)得到当前应用程序的路径 
    MsgBox(Environment.CurrentDirectory)MsgBox可以换为C#目前版本的如:MessageBox.Show.....
      

  4.   

    AppDomain.CurrentDomain.SetupInformation.ApplicationBase
    也成
      

  5.   

    System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);