zoukankan      html  css  js  c++  java
  • 学习:C#中获取当前路径的几种方法(转)


       要在c#中获取路径有好多方法,一般常用的有以下五种:

        //获取应用程序的当前工作目录。 
        String path1 = System.IO.Directory.GetCurrentDirectory();             
        MessageBox.Show("获取应用程序的当前工作目录:" + path1);

        //获取程序的基目录。
        String path2 = System.AppDomain.CurrentDomain.BaseDirectory;         
        MessageBox.Show("获取程序的基目录:" + path2);

        //获取和设置包括该应用程序的目录的名称。
        String path3 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;             
        MessageBox.Show("获取和设置包括该应用程序的目录的名称:" + path3);

        //获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
        String path4 = System.Windows.Forms.Application.StartupPath;            
        MessageBox.Show("获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称:" + path4);

        //获取启动了应用程序的可执行文件的路径及文件名
        String path5 = System.Windows.Forms.Application.ExecutablePath;            
        MessageBox.Show("获取启动了应用程序的可执行文件的路径及文件名:" + path5);


    文章来源:http://www.cnblogs.com/purplefox2008/archive/2009/06/04/1495873.html

  • 相关阅读:
    SpringBoot连接数据库
    String、StringBuffer、StringBulider的区别和解析
    异常This application has no explicit mapping for /error
    node使用
    JS总结defer与async(一)
    前端项目搭建与知识框架
    git ssh配置总结
    JS算法
    JS数据结构
    Http与Http2与Https区别和联系
  • 原文地址:https://www.cnblogs.com/LeimOO/p/1596802.html
Copyright © 2011-2022 走看看