This maybe a simple question, but how do i get all files in a folder except the .zip extension. I have a foreach loop as follow :
foreach (DirectoryInfo directory in directories)
{
foreach (FileInfo file in directory.GetFiles("*.*"))
{
}
}
Should I do an if statement inside second loop and check if (file.Name.contains("zip")) then continue or is there a better way?
FileInfohas a propertyExtensionwhich will give you the string representing of the extension for each file.Edit:
You can use this LINQ query to simplify your code: