How to Use If - then in assign activity to write multiple lines of code

Hello Forum,

I want to implement this code in single assign activity.

Link = Link .Substring(Link .IndexOf(‘:’) - 1);
Link = System.IO.Path.GetPathRoot(Link );
DriveInfo drive = new DriveInfo(Link );
return drive.DriveType == DriveType.Network ? true : false;

How to do that? If not all atleast 1st few lines in single assign by using IF - THEN? Possible?

@shubhamkumar.tiwari

Try this…you can assign to a boolean variable

bool_Variable = If(new DriveInfo(System.IO.Path.GetPathRoot(Link.Substring(Link.IndexOf(':') - 1))).DriveType==DriveType.Network,True,False)

Getting error as “Expression expected”.

Hi,

Which language do you use in UiPath? How about the following?

VB

boolVar = new DriveInfo(System.IO.Path.GetPathRoot(Link.Substring(Link.IndexOf(":") - 1))).DriveType=DriveType.Network 

C#

boolVar =  new DriveInfo(System.IO.Path.GetPathRoot(Link.Substring(Link.IndexOf(':') - 1))).DriveType==DriveType.Network

Regards,

1 Like

@shubhamkumar.tiwari

Can you show some screenshot please

Cheers