List files under a directory : Directory « File Directory Stream « C# / CSharp Tutorial






using System;
using System.IO;

public class MainClass
{
  static void Main(string[] args)
  {
    DirectoryInfo MyRoot = new DirectoryInfo(@"c:\projects");
    FileInfo[] MyFiles = MyRoot.GetFiles();
    foreach (FileInfo F in MyFiles)
    {
      Console.WriteLine(F.Name);
    }

  }
}
Testing.txt








15.15.Directory
15.15.1.Get the files from the root directory
15.15.2.Use file filer on a directory
15.15.3.Directory.Exists
15.15.4.Get Current Directory
15.15.5.Get relative path
15.15.6.Changing current directory to c:\\
15.15.7.Delete Directory
15.15.8.Directory Attributes
15.15.9.Use DirectoryInfo to create sub directory
15.15.10.List directory under a directory
15.15.11.List files under a directory
15.15.12.All Directories traverses all sub-directories under the root
15.15.13.Traverse all files under the root
15.15.14.Recursive Directory use
15.15.15.Get DirectoryInfo from FileInfo: name, parent directory name, directory exists
15.15.16.DirectoryInfo: creation time, last write time, last access time
15.15.17.DirectoryInfo: Directory attribute list and Directory contains
15.15.18.Using Directory type
15.15.19.Recursely Explore Directories
15.15.20.Show basic directory info
15.15.21.Modify directory structure
15.15.22.Creating Subdirectory and Manipulating File
15.15.23.Exploring Files And Sub directories
15.15.24.Create directory structure
15.15.25.Get all cs file from current directory, display its creation time, length, name
15.15.26.Use the GetFiles method to return file names from a user-specified location.