Getting names of all the subfolders inside a folder

I have been given task to rename each and every subfolders inside a folder. If the subfolders have more folders I have to rename that too. Can anyone help me with this problem?

We have to check for each folder if there is a folder inside it or not, if it’s present we will go inside folder and rename it and check for existence of other folders in those folder.

Use “Directory.GetFiles(selectFolder,”.",SearchOption.AllDirectories)"

image

You have to do string manipulations in side the body. all the best!

1 Like

What String manipulations?

Ankeeta Priyam
http://www.encyclopedia.com/computing/dictionaries-thesauruses-pictures-and-press-releases/string-manipulation

How to get only subfolder name without getting the whole path

Hello @ushu,

Hope this could help you. You can use Directory.GetDirectories to retrieve all the subfolders and then Path.GetFileName to get the name of each subfolder.

Thanks and best regards,
Susana

3 Likes