ExisitFileCheck

Fantastic
so this will return only one file - a string
rather
lets do one thing
–use a assign activity and mention like
FilePath = Directory.GetFiles(“yourfolderpath”,“*.xlsx”)
where FilePath is a variable of type string array
–now use a if condition like this
FilePath.Count > 0
if the above condition passes it will go to THEN part where we can get the first file path
like we did previously using assing activity
FilePath_1 = Directory.GetFiles(Path,“*.xlsx”).OrderByDescending(Function(d) New FileInfo(d).CreationTime)(0).ToString

where FilePath_1 is a string variable
–next to this use a path exists activity and check whether the path exists or not
and remaining steps same (all inside the THEN part)

hope this would help you
Cheers @balkishan

This is not working

1 Like

Which one buddy
Cheers @balkishan

@balkishan
did that work buddy

Cheers

1 Like

Hi @Palaniyappan I am sure it will work fine. But I need the value in True/False as I have to invoked this workflow in the main and then use the condition further on the base of the true/false result.

Okay understood will implement it bro. Let’s how it’s work :slight_smile:

1 Like

Yes of course we can assign this to a Boolean variable using assign activity
Out_boolean = FilePath.Count > 0

Where Out_boolean is a variable of type Boolean
Which can be taken as OUT argument from this xaml and assign it to a global variable in the main
And that global variable can be assigned as a value to a IN Argument of another invoked workflow xaml

Kindly correct me if I m wrong
Cheers @balkishan

1 Like

Hi @Palaniyappan It’s working fine when there is a file in the directory, when there is no file in the directory then it throw this error as it thrown previously.

Now there is no file in the folder it throw this error, snapshot attached.

1 Like

Hmm
I don’t understand actually it should go to else part when the FilePath.Count < 0 fails
Which actually means there is no file in it
Strange buddy
Cheers @balkishan

1 Like

yes exactly bro, but when assign to boolean it shows the error.

Yes bro, see there is not file in the folder.


And where it goes
image

1 Like

Actually we can enter only a condition and not a assignment of value to a variable
So that’s why
Kindly remove the Isfileexist =
And keep the filepath.Count>0

Fine let’s do one thing
Let’s keep this whole setup inside a try catch
If any exception occurs like if there is no file then it will get to catch block where we can assign a Boolean variable like
Bool_NoFile = True

Where Bool_NoFile is a Boolean variable with default. Value False

Then this variable can be give to an OUT argument as mentioned here

Hope This would work for sure
Cheers @balkishan

1 Like

Doing in the same way only it’s going into the Then and Else block when there is a file or not but boolean result give same False only.


whether there is a file or not.

image

1 Like

Kindly share the xaml pls if possible
Cheers @balkishan

1 Like

File_Check.zip (171.0 KB)

Please find the attachment bro

1 Like

if you check bro it’s not going into the Catch block

1 Like

here you go
hope its resolved
File_Check.zip (17.0 KB)

Cheers @balkishan

1 Like

in the file path kindly change it to your folder path
Cheers @balkishan

1 Like

yeah this is an easy and simple method. But I am wondering why Try Catch is not work there.
Anyway it’s resolved the issue. :slight_smile:
Thanks you bro

1 Like

Cheers @balkishan

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