1
Answer

C# linq no data selected

dc

dc

12y
1.1k
1
In a C# 2008 linq statment that looks at a directory path below, I am having problem with the following code. 
string[] excelFiles = Directory.GetFiles(strFullpath, "*.xlsx")
                                                                 .Select(path => Path.GetFileName(path))
                                                                 .ToArray();
If there are no records selected, the code is caught in a try catch-block.

How can I change the code listed above to check for records when no records are selected  for the string[] excelFiles array?

Also if possible, how can I change the statment above to allow me to check for no records and/or if the string[] excelFiles array is not even created?

Answers (1)