String Manipulation remove string

I have String - Variable → C:\Users\Admin\Desktop\Project\Report 1.pdf, C:\Users\Admin\Desktop\Project\Report 2.pdf, C:\Users\Admin\Desktop\Project\Report 3.pdf,

I have to remove the paths one by one when that file is successfully processed ,so how can i remove that comma separated paths

@Kalpesh_Chaudhari @mohiniganesh15 @Anil_G

Hi @pravin_bindage

Do you want extract only File name out of full file name?
If yes, use Path.GetFileName(“yourVariable”).ToString().

no i want to remove one single file path from that whole string contains a multiple file paths separated by commas

Hi,

You can split that string using delimiter like comma here, you will get array of string containing required path.

arr_variable = str_variable.Split(","c)

iterate using for each on arr_variable to get string path

Mark it as solution if it resolves your issue

Thanks

2 Likes

Use yourVariable.Split(","c), which will return all 3 path as string in a array.

Use array slicing arr(0) to get first path string.

If you want to get only file name one by one, use for loop on spliited array and use Path.GetFileName(item)

how to remove the matching path from that array

Hi @pravin_bindage

You can use the following method to extract & process each file path.

Cheers

Path.GetFileName(“fullPath”) will result “C:\Users\Admin\Desktop\Project\Report 1.pdf” ==> “Report1.pdf”

Hi @pravin_bindage ,

Path.GetFileName(filepath) - it gives full path including extension.
Path.getFileNameWithOutExtension(“fullpath”) - it will give you file name only.
Mark as solution if it is useful !!!

Regards
Mohini

Happy Automation…!!!