How to use File Exists for Dynamic File in Studiox

Hello,

I know a similar issue has been asked before: How to use File Exists for Dynamic File?

But i am not able to replicate the solution as i am using studioX.

I have a file which gets downloaded in the downloads folder by default and i need to check if file exists or not.

FileName as : “File_A 11111.xlsx” , this value “File_A” is constant and follows random number.

How can i use File Exists using wild card?

Thanks in advance.

@josiahgoh276

Pass this

File_A*.xlsx

in the file
exists

Cheers

Hi Shiva,

Thank you for the prompt reply. I have tried but it didn’t work.

I have done what you have advised:
image

Not sure why it doesn’t work

1 Like

Well file exists activity doesn’t accept wildcard as a part of expression

Instead you can try with if condition like this

System.IO.Directory.GetFiles(“Download path”,“File_A*.xlsx”).Any()

Hope this helps

Cheers @josiahgoh276

Hi @josiahgoh276

Try with this expression

Directory.GetFiles(Environment.CurrentDirectory+"\Input\","File_A*.xlsx").Any

image

how do i add a condition to delete the file found if it exists? :open_mouth:

Hi @josiahgoh276

Try like this

Hope this helps!!

@josiahgoh276

for delete you can use Delete file activity

place it in then block

cheers

Hi, i try to combine the delete file activity and the if condition stated above, it didn’t work:

1 Like

Hi @josiahgoh276

Have you tried this

Hi, it didn’t work for me:

The file still stays there:

@josiahgoh276

hi

can you try by this way,its working fine for me

cheers

Hi,
this is working for me. Thanks!

1 Like

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