• C#获取程序目录


    c#中路径写法(@"c:")  or  ("c:\子目录")

    可获得当前执行的exe的文件名。 
    Process.GetCurrentProcess().MainModule.FileName;

    获取该进程从中启动的目录

    Environment.CurrentDirectory;

    备注按照定义,如果该进程在本地或网络驱动器的根目录中启动,则此属性的值为驱动器名称后跟一个尾部反斜杠(如“C:”)。如果该进程在子目录中启动,则此属性的值为不带尾部反斜杠的驱动器和子目录路径

    (如“C:子目录”)。 

    获取应用程序的当前工作目录。
    Directory.GetCurrentDirectory();

    获取基目录,它由程序集冲突解决程序用来探测程序集。

    AppDomain.CurrentDomain.BaseDirectory;

    获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。

    Application.StartupPath;

    获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。

    Application.ExecutablePath;

    获取或设置包含该应用程序的目录的名称。

    AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

    获取模块的完整路径。

    System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName


    获取和设置当前目录(该进程从中启动的目录)的完全限定目录。

    System.Environment.CurrentDirectory

    获取应用程序的当前工作目录。

    System.IO.Directory.GetCurrentDirectory() 

    获取程序的基目录。
    System.AppDomain.CurrentDomain.BaseDirectory

    获取和设置包括该应用程序的目录的名称。
    System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase

    获取启动了应用程序的可执行文件的路径。

    System.Windows.Forms.Application.StartupPath 

    获取启动了应用程序的可执行文件的路径及文件名

    System.Windows.Forms.Application.ExecutablePath
       

  • 相关阅读:
    LVS负载均衡部署
    将源码包制作成rpm包
    root用户被提示:Operation not permitted
    varnish加速web
    优化nginx数据包头缓存
    NGINX并发量优化
    Python+API接口测试框架设计(pytest)
    python+API接口测试框架设计(unittest)
    python编程面试题
    Python + unittest知识点回顾
  • 原文地址:https://www.cnblogs.com/blogpro/p/11338972.html
Copyright © 2020-2023  润新知