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
    ```
  • 相关阅读:
    iOS 改变同一个label中多行文字间的距离
    iOS改变UITableViewCell的分割线frame和颜色
    iOS动画实现改变frme和contenOffset
    iOS判断数组不为空
    jQueryMobile控件之ListView
    jQueryMobile控件之展开与合并
    jQueryMobile控件之页面切换
    jQueryMobile控件之按钮
    jQueryMobile控件之复选框
    jQueryUI 之控件们
  • 原文地址:https://www.cnblogs.com/zhengxia/p/11752722.html
Copyright © 2011-2022 走看看