How to split file path into folders

Hi Team,

File path is given as input and I am trying to split the file path in different folder given below

Input Variable: FilePath “C:\Users\Folder\Desktop\New folder”
Output: Folders string[5] { “C:”, “Users”, “Folder”, “Desktop”, “New folder” }

While Spliting I get output in string[9] { “C:”, “”, “Users”, “”, “Folder”, “”, “Desktop”, “”, “New folder” }

Please help me on how to remove empty space/lines from the above out put

Hi,

Can you try the following expression?

FilePath.Split("\"c,StringSplitOptions.RemoveEmptyEntries)

Regards,

Filepath.Split(new string[] { "\" }, StringSplitOptions.RemoveEmptyEntries)

There is a parameter to remove empty entries from string split

Hi @Yoichi


Its not working giving above error

Hi,

How about the following expression?

FilePath.Split({"\"c},StringSplitOptions.RemoveEmptyEntries)

Regards,

1 Like

Hi @Priyanka_Ramesh

it showing some identifier expected please refer below screen short

HI @Sushma_Ganapatisa

Check with this expression

Split(FilePath,"\\")

You have double slash there so if you use to split with single slash there will be a empty

Regards
Sudharsan

@Yoichi Worked Thanks

1 Like

it is () not

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