dc

dc

  • NA
  • 663
  • 0

C# linq no data selected

Oct 16 2012 3:36 PM
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)