String Manipulation Problem [new DirectoryInfo(Path).Parent]

I’m using this syntax in for each loop–> new DirectoryInfo(Path).Parent.Parent.FullName.ToString
to extract path
1st time it gives me correct result but 2nd time it give wrong result.
1st loop Path–> C:\Users\Uipathuser\Test_Folder_Data_RPA - Documents\Spain\Alberta Corporation\2020\Local Plan\Source Data\Forms210
Result–>C:\Users\Uipathuser\Test_Folder_Data_RPA - Documents\Spain\Alberta Corporation\2020\Local Plan
2nd loop Path -->C:\Users\Uipathuser\Test_Folder_Data_RPA - Documents\Spain\Alberta Corporation\2020\Public Plan\Source Data\Forms210
Result–> C:\Users\Uipathuser\OneDrive - Taxology\RPA\Spanish Claims\Code\SpanishForm\ C:\Users\Uipathuser\Test_Folder_Data_RPA - Documents\Spain\Alberta Corporation\2020\Public Plan
So whats wrong with this syntax

@Anil_G @Sudharsan_Ka @Kalpesh_Chaudhari

What will be in the Path @pravin_bindage

Path is a variable & its value is folder path

It it is a folder path then why are using expression to get the path again @pravin_bindage

Hi @pravin_bindage ,

Could you let us know what are you trying to perform ?

What is the expected output that you require from this path ?

path → C:\Users\Uipathuser\Test_Folder_Data_RPA - Documents\Spain\Alberta Corporation\2020\Local Plan\Source Data\Forms210
Result i want -->C:\Users\Uipathuser\Test_Folder_Data_RPA - Documents\Spain\Alberta Corporation\2020\Local Plan\

i want to remove that last two folder names

@pravin_bindage ,

The result that you are receiving seems to be correct. I believe you are looping through different Folder Paths and hence receiving different outputs at different loops.

Or Could you be more precise on what is being looped and what is happening at the second loop ?

Sorry guys i used split function to split path & it works well

@pravin_bindage ,

Great to know you were able to resolve the issue.

A more precise explanation of the solution used would help others also if faced with a similar issue. :slightly_smiling_face:

1 Like

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