Path类 操作文件类的实例
作者:happy多乐 时间:2023-09-27 12:53:33
// Path类 IO命名空间 静态类 不能创建对象类名.
string str =@"E:\C#程序设计基础入门教程\(第十一天)\122\22\nee.txt";
////int index=str.LastIndexOf ("\\")//最后一出现的位置
////str =str.Substring (index +1);//拿到最后一个文件
////Console.WriteLine(str);
Console.WriteLine(Path.GetFileName(str)); //获得文件名包括扩展名
Console.WriteLine(Path.GetFileNameWithoutExtension(str)); //获得文件名但是不包含扩展名
Console.WriteLine(Path.GetExtension(str)); //获得文件的扩展名
Console.WriteLine(Path.GetDirectoryName(str)); //获得文件所在的文件夹的名称
Console.WriteLine(Path.GetFullPath(str)); //获得文件所在的全路径
Console.WriteLine(Path.Combine(@"E:\C#程序设计基础入门教程\(第十一天)\122\22\", "b.txt")); //连接两个字符串作为路径
Console.ReadKey();
来源:http://www.cnblogs.com/enduo/p/7784692.html
标签:Path类,操作,文件类
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java设计模式之工厂模式
2023-12-18 01:40:50
![](https://img.aspxhome.com/file/2023/9/60339_0s.png)
Java Valhalla Project项目介绍
2021-10-03 00:29:28
![](https://img.aspxhome.com/file/2023/0/83120_0s.png)
Android Listview多tab上滑悬浮效果
2021-07-27 22:06:23
![](https://img.aspxhome.com/file/2023/8/114358_0s.jpg)
Android中AlertDilog显示简单和复杂列表的方法
2022-11-22 16:32:35
C# WinForm实现图片浏览器
2022-04-12 23:28:00
![](https://img.aspxhome.com/file/2023/6/92906_0s.jpg)
Mapper类中存在名称相同的方法重载报错问题
2023-04-04 02:44:39
基于java实现简单发红包功能
2023-08-09 17:06:40
![](https://img.aspxhome.com/file/2023/9/72559_0s.jpg)
Android仿知乎悬浮功能按钮FloatingActionButton效果
2021-08-04 16:33:47
![](https://img.aspxhome.com/file/2023/5/137995_0s.gif)
Android OpenGL仿自如APP裸眼3D效果详解
2023-12-23 21:37:05
![](https://img.aspxhome.com/file/2023/0/88110_0s.png)
C#实现窗体抖动的两种方法
2021-10-06 10:20:52
![](https://img.aspxhome.com/file/2023/6/80056_0s.jpg)
MyBatis中${} 和 #{} 有什么区别小结
2021-09-21 14:42:35
![](https://img.aspxhome.com/file/2023/2/89572_0s.jpg)
springboot如何统一设置时区
2022-01-26 18:16:39
![](https://img.aspxhome.com/file/2023/9/63659_0s.png)
Java之如何关闭流
2023-11-04 21:29:11
Java SpringBoot实现AOP
2023-05-31 05:49:30
![](https://img.aspxhome.com/file/2023/1/63001_0s.png)
Java操作IO对象流进行数据的读写
2021-08-25 03:33:49
mybatis 通过拦截器打印完整的sql语句以及执行结果操作
2023-07-06 04:26:42
Android编程开发之TextView单击链接弹出Activity的方法
2023-08-06 18:27:11
![](https://img.aspxhome.com/file/2023/4/83544_0s.png)
C# javascript 读写Cookie的方法
2023-03-19 08:03:16
VSCode中开发JavaWeb项目的详细过程(Maven+Tomcat+热部署)
2022-10-18 14:42:10
![](https://img.aspxhome.com/file/2023/1/122281_0s.jpg)
C++类静态成员与类静态成员函数详解
2022-10-10 08:22:20