dc

dc

  • NA
  • 663
  • 0

C# using linq on file name

Jan 17 2013 1:20 AM
In a C# 2008 desktop application, I can using the following statement to select error reports that are displayed on excel spreadsheets:

string[] excelFiles = Directory.GetFiles(strFullpath, "*ErrorReport.xlsx")
                                                                     .Select(path => Path.GetFileName(path))
                                                                     .ToArray();

Due to the above, I have the following questions:
1. if I want to change the statement to select either "*bErrorReport.xlsx" or "*dErrorReport.xlsx" or "*ErrorReport.xlsx",
how would I change the  statement I just displayed?
2. The above statement picks 3 excel spreadsheets and there are really only two excel spreadsheets. The excelspreadshets that are valid
   include:
   customer_number_bErrorReport.xlsx,
   and   customer_number_ErrorReport.xlsx.

   The invalid value that is selected is
    ~customer_number_bErrorReport.xlsx.

Can you show me the code, so an invalid spreadsheet called ~customer_number_bErrorReport.xlsx is not selected?

Answers (1)