zoukankan      html  css  js  c++  java
  • C# 获取程序路径的主要方法和区别如下

    C# 获取程序路径的主要方法和区别如下:

    ```csharp
    //1.获取模块的完整路径(即程序名+.vshost.exe)是visual studio宿主应用程序,vs运行调试时是打开的其实是这个文件,这个程序可以让vs跟踪调试信息。
    string path1 = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
    //C:UsersAdministratorDocumentsVisual Studio 2015ProjectsSD_MyTestinDebugSD_MyTest.vshost.exe

    //2.获取和设置当前目录(该进程从中启动的目录)的完全限定目录
    string path2 = System.Environment.CurrentDirectory;
    //C:UsersAdministratorDocumentsVisual Studio 2015ProjectsSD_MyTestinDebug

    //3.获取应用程序的当前工作目录
    string path3 = System.IO.Directory.GetCurrentDirectory();
    //C:UsersAdministratorDocumentsVisual Studio 2015ProjectsSD_MyTestinDebug

    //4.获取程序的基目录
    string path4 = System.AppDomain.CurrentDomain.BaseDirectory;
    //C:UsersAdministratorDocumentsVisual Studio 2015ProjectsSD_MyTestinDebug

    //5.获取和设置包括该应用程序的目录的名称
    string path5 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
    //C:UsersAdministratorDocumentsVisual Studio 2015ProjectsSD_MyTestinDebug

    //6.获取启动了应用程序的可执行文件的路径
    string path6 = System.Windows.Forms.Application.StartupPath;
    //C:UsersAdministratorDocumentsVisual Studio 2015ProjectsSD_MyTestinDebug

    //7.获取启动了应用程序的可执行文件的路径及文件名
    string path7 = System.Windows.Forms.Application.ExecutablePath;
    //C:UsersAdministratorDocumentsVisual Studio 2015ProjectsSD_MyTestinDebugSD_MyTest.EXE
    ```

  • 相关阅读:
    java Math类方法使用
    线性逻辑回归与非线性逻辑回归pytorch+sklearn
    Java学习方向
    ubuntu16.04安装Anaconda+Pycharm+Pytorch
    迁移学习resnet
    简单的CNN图像分类datasets.MNIST/FashionMNIST
    pytorch学习2
    tools/build.c
    zBoot/Makefile
    tools/version.c
  • 原文地址:https://www.cnblogs.com/liangyuwen/p/13205374.html
Copyright © 2011-2022 走看看