So, I want to write the file names of a certain directory to a text file. For my program I only need the file names, not the full path. I already put them in an array like so:
string[] charDir = Directory.GetFiles(SettingsInit.Default.GameDir + @"\stages", "*.def", SearchOption.TopDirectoryOnly);
The output of Directory.GetFiles()
are the full paths, e.g.:
C:\Users\%username%\Desktop\mugen_1.1\stages\radicalHighway.def
How can I remove the path from each item, so that I only get the file name? I thought about iterating through each item, but I don't know how to achieve this properly. Since I'd always write charDir[charDir.ToString().IndexOf(i)]
in the foreach loop, I'm not sure if it would work this way.