HI
Currently i am filtering file with xls extension using below action.
strList =Directory.EnumerateFiles(FolderName, “*.xls”).ToList
how can i modify above condition so that i can filter “xls” and “xlsx” file only
HI
Currently i am filtering file with xls extension using below action.
strList =Directory.EnumerateFiles(FolderName, “*.xls”).ToList
how can i modify above condition so that i can filter “xls” and “xlsx” file only
you should be able to do it like
strList =Directory.EnumerateFiles(FolderName, “*.xls*").ToList
Thanks ![]()
Hi @TUSHAR_DIWASE
Use + icon to add additional file format.
Please try the following expression:
strList = Directory.EnumerateFiles(FolderName, "*.xls").Where(Function(file) file.ToLower().EndsWith(".xls") Or file.ToLower().EndsWith(".xlsx")).ToList()
Hope this helps,
Best Regards.
ou can use the Directory.GetFiles method instead Directory.EnumerateFiles
Can you try with this expression?
Directory.GetFiles("Your FolderPath", "*.xls*").Where(Function(r) r.ToLower().EndsWith(".xls") OrElse r.ToLower().EndsWith(".xlsx")).ToList()
Regards
Gokul
Hi @arjunshenoy ,
thanks . actually i wanted all file of extension xls and xlsx. i modified below bold part and it work . thanks
strList = Directory.EnumerateFiles(FolderName, “*.*”).Where(Function(file) file.ToLower().EndsWith(“.xls”) Or file.ToLower().EndsWith(“.xlsx”)).ToList()
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.