How to get the sub-folder path from a File-path

I have a requirement where I am moving the file from one sub folder to another:
image
In order to do so I need to get the sub-folder path: This is the full path:
C:\Users\svcUpChtPreDSHS\Desktop\FakeSharedDrive\Process\CHET\11.15.2023 Nurse DONE\MF NO\Peterson.pdf"

I want to get this path:
C:\Users\svcUpChtPreDSHS\Desktop\FakeSharedDrive\Process\CHET\11.15.2023 Nurse DONE

Although I am using Split string, is there a better way to do it?
Thanks.

Hi @chauhan.rachita30

Can you try the below

str_Input="C:\Users\svcUpChtPreDSHS\Desktop\FakeSharedDrive\Process\CHET\11.15.2023 Nurse DONE\MF NO\Peterson.pdf"
str_Output=Path.GetDirectoryName(Path.GetDirectoryName(str_Input))

Cheers!!

1 Like

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