How to check if the file exists in folder without passing file extension(PDF, Doc, Docx)

Type of reusable component:


Current Behavior:

Expected Behavior:

Studio/Robot/Orchestrator Version:

I need to send mail by adding attachment which are present in folder.

First, I need to read data from one folder there I get attachment filename with extension and then I need to search in Attachments folder whether the file exists or not. If Exists I need to attach that attachment and send mail.

**Main.xaml (9.7 KB)
** I need to search weather the file exists in folder with passing the file extension (.pdf, .doc, .docx).

string[] files = System.IO.Directory.GetFiles(path, "filename.*");
if (files.Length > 0)
    //file exist

I have tried but it didn’t worked can you please update my solution and post it.

Did you got any error ?
I don’t see any issue with the code.
can you try hard coding the values of path and file name and check.
If it works, then you are passing the wrong values in the variables.

Hey Thank you for your support. It works fine. @KarthikByggari

1 Like

Hi @KarthikByggari here you have mentioned the finename, but we don’t know the file name we’re just checking it right,
so we can give like this also na “*.extension” . Right me if I am wrong.

I given the assigned like this to the array file variable. image

But I have multiple extension files, So how to give the extension.

You can mention multiple extensions like below -

string files = System.IO.Directory.GetFiles(path, “*.extension1, *.extension2”)

1 Like

Thanks Bro really helpful :slight_smile: