当前位置:网站首页>C filters Excel files with ". XLS" and ". Xlsx" suffixes from the folder

C filters Excel files with ". XLS" and ". Xlsx" suffixes from the folder

2020-12-08 10:18:39 New cool, not summer

1 I'm doing some reading recently Excel File some operations , encounter winform load Excel file

2 To start with FileInfo[].GetFiles("*.*") Read it all , You can't screen Excel

3 see Msdn Find out What this method does :

  • "*.abc" Will return file with extension of.abc,.abcd,.abcde,.abcdef.

  • "*.abcd" Only return files with extension of.abcd.

  • "*.abcde" Only return files with extension of.abcde.

  • "*.abcdef" Only return files with extension of.abcdef.

4 therefore

DirectoryInfo directoryInfo = new DirectoryInfo(pathDir);

FileInfo[] fileInfos = directoryInfo.GetFiles("*.xls", SearchOption.AllDirectories);

such “.xls” and “.xlsx” All the documents can be screened out ...

 

版权声明
本文为[New cool, not summer]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/202012081018258825.html