C#控制台基础 给一个字符串是文件的全称,分离出来文件的类型与名字
2016-09-05 19:10
309 查看
慈心积善融学习,技术愿为有情学。善心速造多好事,前人栽树后乘凉。我今于此写经验,愿见文者得启发。
感恩曾经帮助过 心少朴 的人。
C#优秀,值得学习。Console,ASP.NET,Winform,WPF,设计模式等都可以关注一下,眼界要开阔。
Visual Studio IDE很好用,推荐!
注:此文是自学笔记所生,质量中等,故要三思而后行。新手到此,不可照搬,应先研究其理象数,待能变通之时,自然跳出深坑。
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication8 { class Program { static void Main(string[] args) { string fullName = "CSharp2.2.txt"; int index = fullName.LastIndexOf('.'); string fileType = fullName.Substring(index+1, fullName.Length - index-1); Console.WriteLine("文件的类型是:"+fileType); string fileName = fullName.Substring(0,index); Console.WriteLine("文件名是:"+fileName); Console.ReadKey(); } } }
感恩曾经帮助过 心少朴 的人。
C#优秀,值得学习。Console,ASP.NET,Winform,WPF,设计模式等都可以关注一下,眼界要开阔。
Visual Studio IDE很好用,推荐!
注:此文是自学笔记所生,质量中等,故要三思而后行。新手到此,不可照搬,应先研究其理象数,待能变通之时,自然跳出深坑。
相关文章推荐
- Python3基础 os.path.basename 对一个路径字符串进行处理 返回 文件的名字
- java如何在文件中读取一个字符串并创建以这个字符为名字的类的对象
- 写一个方法,参数接收一个String类型的对象,最终可以把这个字符串参数中出现过的每一个字母打印出来 例如: "wwqweqdasdafdsfdsferer" 将来方法接收这个参数后会打印:
- C#控制台基础 directory获取一个文件夹中所有文件及文件夹的绝对路径
- 在一个文件末尾增加字符串,并在控制台打印出来
- C#控制台基础 directory.getfiles 找到指定路径下的指定类型文件
- [Shell]在一个目录及其子目录内的指定类型的文件中搜索某个字符串
- C#控制台基础 directory获取一个文件夹下所有文件夹的名字(不包含文件)
- C#控制台基础 应用dictionary记录一个string字符串中各个字符出现的次数
- Python读取文件中一串字符串并且把其中所有的数字组成一个新的字符串,并且打印出来
- grep 忽略大小写查找某一个路径下某一文件类型中的字符串
- java梳理-给一个字符串类型的数字,不调用java直接转的API写一个方法转换出来
- C#控制台基础 path.changeextension一个路径字符串中的文件扩展名
- C#控制台基础 directory获取一个文件夹下所有文件的名字(不包含文件夹)
- 怎么根据基本类型的名字字符串,判断一个值是否在一个范围内
- C#控制台基础 assembly与gettypes获取一个dll中的类的名字
- C#控制台基础 filestream将string字符串写入一个新建的txt文件中
- C#控制台基础 将一个string数组合并成一个string字符串,以空格隔开
- Java基础知识强化之IO流笔记52:IO流练习之 把一个文件中的字符串排序后再写入另一个文件案例
- Java IO把一个文件中的内容以字符串的形式读出来