String breaking - plz help

hi all

I want to break the following string
In uipath i m not able to get the string before \ – the 2nd slash

C:\Smart project\TestT666.CSV

from above string i just need only —C:\Smart project

How to Do this???

Please help

Hy @Seem

You can try this :slight_smile:

assign : string1 = “ C:\Smart project\TestT666.CSV

string1.Split(“\”)(0)+“\”+string1.Split(“\”)(1)

1 Like

@Seem You can use regex like as shown below

                      assign str = “ **C:\Smart project\TestT666.CSV** ”

                      assign str = System.Text.RegularExpressions.Regex.Match(str,".*(?=\\)").ToString

So Now str will have ** C:\Smart project**

If you are after getting the directory name from the full path string you could try the following:
directory = Io.Path.GetDirectoryName(" C:\Smart project\TestT666.CSV")

Cheers

Hi,
Try this
“C:\Smart project\TestT666.CSV”.Substring(0,16)

@Seem

Use below code in assign activity or message box

Path.GetDirectoryName(“C:\Smart project\TestT666.CSV”)

It returns as you expected like this C:\Smart project