从一个文件名字符串中删除文件扩展名 [英] Remove file extension from a file name string

查看:598
本文介绍了从一个文件名字符串中删除文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个字符串说的abc.txt,有没有快速的方法来得到一个子,这只是ABC

If I have a string saying "abc.txt", is there a quick way to get a substring that is just "abc"?

我不能做一个 fileName.IndexOf('。'),因为文件名可以是abc.123.txt或东西,我明明只是想摆脱的延长(即abc.123)。

I can't do an fileName.IndexOf('.') because the file name could be "abc.123.txt" or something and I obviously just want to get rid of the extension (i.e. "abc.123").

推荐答案

的<一个href=\"http://msdn.microsoft.com/en-us/library/system.io.path.getfilenamewithoutextension.aspx\"><$c$c>Path.GetFileNameWithoutExtension方法为您提供了通过不带扩展参数文件名,如应该是清楚的名称。

The Path.GetFileNameWithoutExtension method gives you the filename you pass as an argument without the extension, as should be obvious from the name.

这篇关于从一个文件名字符串中删除文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆