I have a path string which is like this
Example 1 - C:\Ishan\UiPath Robots\Test\ST36702302070006.pdf
Needed Result is :
C:\Ishan\UiPath Robots\Test\ST36702302070006 - unlocked.pdf
Just an example. there can be anything before .pdf
Example 2 - C:\Ishan\UiPath Robots\Test\ABC.pdf
Needed Result is :
C:\Ishan\UiPath Robots\Test\ABC - unlocked.pdf
Any suggestions ?
1 Like
HI @Ishan_Shelke
Checkout this
"C:\Ishan\UiPath Robots\Test\ABC.pdf".Insert("C:\Ishan\UiPath Robots\Test\ABC.pdf".IndexOf(".pdf")," - unlocked")
Likewise for all the strings
Regards
Sudharsan
jack.chan
(Jack Chan)
3
assuming your path is in a variable called “testString”
do this:
Path.Combine(Path.GetDirectoryName(testString),Path.GetFileNameWithoutExtension(testString)+"-unlocked" + Path.GetExtension(testString))
@Ishan_Shelke

Hi @Ishan_Shelke ,
You can do the following:
- You can split the string
- get the first item on the array.
- Combine the second string and “.pdf”
Example:
strPath = “C:\Ishan\UiPath Robots\Test\ST36702302070006.pdf”
strSecondValue = “- unlocked.pdf”
strPath= strPath.Split(“.pdf”)(0)
NOTE: The value of strPath now will be “C:\Ishan\UiPath Robots\Test\ST36702302070006”
strFinalPath = strPath + strSecondValue
NOTE: strFinalPath value will be “C:\Ishan\UiPath Robots\Test\ST36702302070006 - unlocked.pdf”
I hope this helps. Happy automation!
Kind regards,
Kenneth
Perfect. Thanks @Sudharsan_Ka
1 Like
system
(system)
Closed
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.