0 probing folders
1 Code
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.IO;4 usingSystem.Linq;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 namespaceConsoleApplication29 {Ten class Program One { A Static voidMain (string[] args) - { - //under the specified path the stringPath =@"l:\"; - //the name of the folder - stringAfilename ="folders created with the program"; - + //absolute path to file - string[] FilePath =Directory.GetFiles (Path.Combine (Path, Afilename)); + //absolute path to folder A string[] DirectoryPath =directory.getdirectories (Path.Combine (Path, Afilename)); at - //It 's more convenient to use this to add the absolute path of files and folders to a list collection -list<string> Fileanddirectorypath =filepath.tolist (); - Fileanddirectorypath.addrange (directorypath); - - in foreach(varIteminchFileanddirectorypath) - { to Console.WriteLine (Path.getfilename (item)); + } - the * Console.readkey (); $ }Panax Notoginseng } -}
2 effects
C # console Basic directory Gets the full name of all files and folders under a folder