I have the following code and I'm trying to make sure it adds only to a listbox if it finds the .PLT file extension. For some reason its still adding all the files it finds. I would also like to change whats below to account for more than one file type extensions. For example, I may want to check for .PDF and .doc files that are in a collection. Instead of running the collection and then doing the file search what is the best method to keep the searching from only performing once?
foreach (string fileName in fileEntries)
{
// do something with fileName
Directions = Path.GetFileName(fileName)
;
Console.WriteLine(Directio
ns.LastInd
exOf(".plt
"));
if (Directions.LastIndexOf(".
plt") !=0 || Directions.LastIndexOf(".P
LT") !=0)
{
//theName = Path.GetFileName((fileName
));
//theName = (fileName);
lstFrom.Items.Add(Directio
ns);
}
}
Start Free Trial