Get files excluding a certain file extension

Hi,

Is there anyway to get a list of files from a directory excluding a zip for example. I just want to be able to get all the files without naming all the extension I do want like Directory.GetFiles(filepath,".pdf",".csv") and etc. I tried researching but can’t seem to find a solution.

Thanks!

1 Like

Hiii…

You can achieve this in many ways.

  1. Assign str filelist= directory.GetFiles("folder_path").Except(directory.GetFiles("folder_path","*.zip")).ToArray
    or,
  2. Assign str filelist = directory.GetFiles("folder_path").Where(Function(n) path.GetExtension(n) <>".zip").ToArray
    For reference, please check the workflow.:grinning: Exclude_extension.xaml (13.6 KB)

Regards,
Nimin

3 Likes

Hey Nimin,

Awesome, it works :blush: Thanks!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.