Hi. I want to extract a string before the last symbol in a file path “" for an example path “C:\Users\AAAA\Downloads\Testfile.xlsx” but keep getting to after the last symbol using this InputPath.Substring(InputPath.LastIndexOf(”")+"".Length).Split(Environment.NewLine.ToCharArray)(0) which returns the string Testfil.xlsx. Can anyone suggest a correct command please?
Hi @ciaramkm
did u need to extract the filename from filepath given ?
No just the filepath before the last \ given
Can u provide an example of the data u need to extract , i am still not cleared
Input: C:\Users\AAAA\Downloads\Testfile.xlsx
Output: C:\Users\AAAA\Downloads
Hi @ciaramkm
use this method
Directory.GetParent(“C:\Users\AAAA\Downloads\Testfile.xlsx”)
This will give the output like this
C:\Users\AAAA\Downloads
Regards,
Nived N
Happy Automation
2 Likes
Inputpath.substring(0,(Inputpath.lastindexof(“”))) can also be used.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.