المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : C# use linq for on filename



C# Programming
01-17-2013, 11:11 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?