Path类
2015-08-16 08:47
232 查看
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace _14Path类 { class Program { static void Main(string[] args) { string str = @"C:\3000soft\Red Spider\Data\Message\老赵.wav"; //获得文件名 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(@"c:\a\" , "b.txt")); //int index = str.LastIndexOf("\\"); //str = str.Substring(index + 1); //Console.WriteLine(str); Console.ReadKey(); } } }
相关文章推荐
- poj 2226 二分图最小点覆盖
- (转)C#生成中文汉字验证码源码(webform)
- 告别了一段时间
- HDU 1399 Starship Hakodate-maru
- Android Studio 快捷键
- hdu 5391 Zball in Tina Town
- fork()的详解
- 垂直居中
- B/S 类项目改善的一些建议
- web验证码
- ios移动开发博客网址收藏
- Java进阶(十四)实现每天定时对数据库的操作
- hdu 5392 Infoplane in Tina Town
- Java进阶(十四)实现每天定时对数据库的操作
- poj2481-Cows
- 类型转换
- CentOS 菜鸟日记
- 杂谈:余佳文的认怂是缺乏诚信吗?
- 关于Javascript的闭包
- BI—脚不一样的感觉