Getting the Directory Name

Hi i need to fetch only the directory name from a path like C:\Users\abc\Documents\UIPATH\Project1\datareport
datareport is the folder and i want to get only folder name

Hi @Tel43,

You can iterate on the following path like,

for each folder in Directory.GetDirectories(Path)
{
Path.GetFileNameWithoutExtension(folder)
}

Let me know in case of further queries…
Thanks :slight_smile:

yes it worked,but why is it giving me the folder name?
although it specifies GetFileNameWithoutExtension

Actually, we are iterating on the folders only, and passing the folder path in the loop…

So its giving the folder name only to you…

ok got it, Thanks alot

1 Like