How to include 'Or' in assign acitivity

Hi all,

I am trying to figure out if it is possible to include Or in assign activity as I would need to check if the file is .pdf or .xls

Here is an example of how my assign looks


The configFileName is to assign every name in the variable ‘arrStr’ in to variable ‘item’

Here is the pathing that I am currently using
“C:\Users\mes2301i\Downloads\Example Folder"+item.ToString+”.pdf"

Thanks

@SRoyi

Check out ternary operators: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/conditional-operator

Let me know if that’s what you need or if you need more help

Thanks for the link man, I’ll go and check it right now and let you know.

Cheers

1 Like

Hi,

Can you elaborate what you want to achieve? Basically Or operator returns true/false and it may not be useful for your purpose as it is.

Regards,

Hi,

what I am trying to achieve is after looping through my variable arrStr, if there are filenames in that array that is found in my intended folder, then my boolean ‘exists’ will return True, else false. Refer to the image below for reference.

cheers

Hey there Argin,

I have checked the link but the operator cannot be used in my case.

Basically what I am try to achieve is:

“C:\Users\mes2301i\Downloads\AWB Automation Development Files"+item.ToString+”.pdf" Or “C:\Users\mes2301i\Downloads\AWB Automation Development Files"+item.ToString+”.xls"

However when I do that, It will say "Option Strict On disallows implicit conversions from ‘String’ to ‘Long’

Cheers

@SRoyi

Depending on what value do you decide if it is pdf or xls?

You should be using a if condition on that variable can use teo assign like you used for file exists

Or can use if(your condition,"….pdf","….xls)

Cheers

Hi,

How about the following?

System.IO.File.Exists("C:\Users\mes2301i\Downloads\AWB Automation Development Files"+item.ToString+".pdf") OrElse  System.IO.File.Exists("C:\Users\mes2301i\Downloads\AWB Automation Development Files"+item.ToString+".xls")

Regards,

Ok sure man. I have found another solution to the problem now.

Still, thanks for you help and prompt reply!

1 Like

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