[csharp] view plain copy
class Program
{
static void Main(string[] args)
{ //获取当前运行程序的目录
string fileDir = Environment.CurrentDirectory;
Console.WriteLine("当前程序目录:"+fileDir); //一个文件目录
string filePath = "C:\\JiYF\\BenXH\\BenXHCMS.xml";
Console.WriteLine("该文件的目录:"+filePath); string str = "获取文件的全路径:" + Path.GetFullPath(filePath); //-->C:\JiYF\BenXH\BenXHCMS.xml
Console.WriteLine(str);
str = "获取文件所在的目录:" + Path.GetDirectoryName(filePath); //-->C:\JiYF\BenXH
Console.WriteLine(str);
str = "获取文件的名称含有后缀:" + Path.GetFileName(filePath); //-->BenXHCMS.xml
Console.WriteLine(str);
str = "获取文件的名称没有后缀:" + Path.GetFileNameWithoutExtension(filePath); //-->BenXHCMS
Console.WriteLine(str);
str = "获取路径的后缀扩展名称:" + Path.GetExtension(filePath); //-->.xml
Console.WriteLine(str);
str = "获取路径的根目录:" + Path.GetPathRoot(filePath); //-->C:\
Console.WriteLine(str);
Console.ReadKey(); }
}

最新文章

  1. Dubbo学习之简单环境搭建
  2. javascript面向对象系列第二篇——创建对象的5种模式
  3. angularjs---select使用---默认值及联动
  4. Asp.net的request类
  5. Selenium调用Chrome,Firefox,IE
  6. EXTJS 3.0 资料 控件之 GridPanel属性与方法大全
  7. MVC入门
  8. c++怎样让返回对象的函数不调用拷贝构造函数
  9. ural 1073.Square Country(动态规划)
  10. Linux系统安装_Centos6.9
  11. Linux运维老司机:CentOS6.9配置安装并配置Rsync
  12. mac配置自带vim高亮显示
  13. UEFI Shell命令操作总结
  14. vue脚手架的使用
  15. OO最后一次作业
  16. 「洛谷P1516」 青蛙的约会
  17. 1-express学习
  18. over()的用法
  19. libvirt的security
  20. Applese走迷宫-bfs

热门文章

  1. 【转】每天一个linux命令(15):tail 命令
  2. 使用过的bug跟踪系统
  3. webpack 遇到报错情况及解决
  4. osql执行数据库查询命令并保存到txt文件
  5. AppBox下调用HighCharts画曲线
  6. 洛谷 3706 [SDOI2017]硬币游戏——思路
  7. 启动ECLIPSE时,提示找到不 eclipse\jre\bin\javaw.exe
  8. vue 操作数组,原数组怎么不让它改变
  9. 第3章 文件I/O(5)_五种I/O模型
  10. ubuntu18.04 安装hadoop 2.7.3+hive 2.3.4