Path Exists Wildcards

Hi, I need to know if multiple files exist in a folder, but only those that start with the same name.
If a file with that name exists, a process must be started and, if it does not exist, a message appears.
I did all the processes with Flow Decision but I can not get Path Exists to work

Thanks in advance

Lucas

Hi Lucas!

Why you not get all the files in the folder, store them in an array and after that check if there is a file with the name that you want?

3 Likes

ok i’m going to try that, thanks

1 Like

Hello again

I do not know how to continue. I already have the names of the files I need with System.IO.Directory.GetFiles but how do I start the process if the file I need exists previously checked by GetFiles. Can I use Flow Decision or If?

  • Assign FileNames = Directory.getfiles(“Folderpath”)
  • If Left(FileNames(0),5) = Left(FileNames(1),5)
    • Yes, Proceed with process.
    • No, output Message.

@Vivek_Arunagiri

Have you provided correct folder path in getfiles?

Also, Check the length of FileNames.

Writeline → FileNames.Length.ToString

Yes, When there are files in the folder it works fine, the problem is when the folder is empty.

Have another if condition to check FileNames.Length>1. If yes, Process

Or else, place it inside Try catch block.

Should I establish another If condition before what I already have? If yes, process with the nextone? Sorry im new using RPA

Yes, you are correct.

It works perfect, thanks!

1 Like

Directly use

string[] files = Directory.GetFiles(path, "filename*")

You ll get the files starting with filename.

1 Like

Great. If you got solution, please mark it as solved :slightly_smiling_face:

Main.xaml (7.0 KB)
Hi,
In my case I there is 6 files in folders. I use the for each. The flow is iterated 6 time in loop but it gives output like Systrem.String , Not exact file name.
Please check my workflow.

You are using Directory.GetFileSystemEntries ( Folder ,“*”) which is incorrect.
Please use Directory.GetFiles

Untitled

Still got above output six times because I have six files in folder but not exact files names.
@palindrome

Main.xaml (7.1 KB)

Please check my workflow.
@palindrome

variable in message box should be filename.
type argument of for each should be string.

2 Likes

It’s perfectly working for me.
You are amazing.
Thanks @palindrome

1 Like