_01IO流显示文件夹的方式

 1 using System;
 2 using System.Collections.Generic;
 3 using System.IO;
 4 using System.Linq;
 5 using System.Text;
 6 using System.Threading.Tasks;
 7 
 8 namespace _01IO流
 9 {
10     class Program
11     {
12         static void Main(string[] args)
13         {
14             string path =@"C:\Users\Administrator\Desktop\1.text";
15             int index = path.LastIndexOf("\\");
16            
17             Console.WriteLine(path.Substring(index+1,1));//传统切割
18 
19             //Console.WriteLine(Path.GetExtension(path));//显示后缀名
20             //Console.WriteLine(Path.GetFileName(path));//文件名字和后缀
21             //Console.WriteLine(Path.GetFileNameWithoutExtension(path));//只单独显示名字
22 
23         }
24     }
25 }

猜你喜欢

转载自www.cnblogs.com/satanj/p/9668005.html