zoukankan      html  css  js  c++  java
  • C#获取当前路径,获取当前路径的上一层路径

    C#获取当前路径的方法如下:

    (1)string path1 = System.Environment.CurrentDirectory;
    //C:...inDebug

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

    (2)string path2 = System.IO.Directory.GetCurrentDirectory();
    //C:...inDebug

    -获取应用程序的当前工作目录。网上说这个方法得到的不一定是程序从中启动的目录,我试的和(1)的结果一样,证明有时得到的还是程序从中启动的目录。

    (3)string path3 = System.Windows.Forms.Application.StartupPath;
    //C:...inDebug

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

    (4)string path4 = System.AppDomain.CurrentDomain.BaseDirectory;
    //C:...inDebug

    -获取基目录,它由程序集冲突解决程序用来探测程序集。
    (5)string path5 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
    //C:...inDebug

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


    (6)string path6 = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
    //C:...inDebugWindowsFormsApplication1.vshost.exe

    -获取模块的完整路径。
    ()7string path7 = System.Windows.Forms.Application.ExecutablePath;
    //C:...inDebugWindowsFormsApplication1.EXE

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

    当前路径与相对路径的合并:
    string path8 = System.IO.Path.GetFullPath(System.IO.Path.Combine(path1, @"....objx86Debug"));
    string[] array = System.IO.Directory.GetFiles(path8);

  • 相关阅读:
    h5 喜帖
    h5 录音
    UglifyJS-- 对你的js做了什么
    SimpleCaptcha生成图片验证码内容为乱码
    Spring.profiles多环境配置最佳实践
    eclipse maven 导出项目依赖的jar包
    cygwin下切换到其他磁盘
    chrome 浏览器的插件权限有多大?
    windows系统tomcat日志输出至catalina.out配置说明
    Windows10远程报错:由于CredSSP加密Oracle修正
  • 原文地址:https://www.cnblogs.com/diyishijian/p/3690194.html
Copyright © 2011-2022 走看看