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

  • 相关阅读:
    423. Reconstruct Original Digits from English
    400. Nth Digit
    397. Integer Replacement
    396. Rotate Function
    365. Water and Jug Problem
    335. Self Crossing
    319. Bulb Switcher
    线段树-hdu2795 Billboard(贴海报)
    线段树---求逆序数
    线段树——单点替换区间最值
  • 原文地址:https://www.cnblogs.com/LeimOO/p/1596802.html
Copyright © 2011-2022 走看看