【发布时间】:2019-12-25 07:43:50
【问题描述】:
我试图获取不带扩展名的文件名,我有以下代码让我可以获取带有扩展名的文件名
var docName = new DirectoryInfo("C:\\files\\").GetFiles("*.docx");
我使用该代码获取所有文件名,然后在
上使用它们 for(int a = 0; a < docLength; a++)
{
Consol.WriteLine("Your File Name : {0}", docName[a] ) // this part is just ex.
}
当我执行程序时,它会列出文件名,如
Test.txt
test.docx
等等
我怎样才能获得没有扩展名的文档名称
test
【问题讨论】:
-
看看System.IO.Path类的方法