Need to iterate through Files and sub folders in a directory

@Debartha_Mitra_DE - Please try this…

Path.GetFileNameWithoutExtension(path.GetDirectoryName(File))

path.GetDirectoryName(File) → This will first just directory Name of that file…

Path.GetFileNameWithoutExtension → Even though you think GetFileNameWithoutExtension will get you only filenames without extension, but when you pass the entire folderpath to this command will print just last Part…which is Test1 and Test2…

Output:
image

Hope this helps…

1 Like