IF activity condition: If there is only 1 file in folder

I am trying to write a condition to check whether there is only one file in a folder or not.

i tried using Directory.GetFiles(foldersource, “.xlsx”, SearchOption.AllDirectories).Count <> 1 but it wasn’t accurate.

How can I make such a condition?

Hi @dvn,

Pls try this solution.Let me know if you have any issues.

Directory.GetFiles(“foldersource”,"*.xlsx",SearchOption.AllDirectories).Length<>1

[https://stackoverflow.com/questions/23081412/check-if-folder-contains-files-with-certain-extensions]

Regards,
Omkar P

1 Like