C# Directory EnumerateFileSystemEntries(String)
Description
Directory EnumerateFileSystemEntries(String)
Returns
an enumerable collection of file-system entries in a specified path.
Syntax
Directory.EnumerateFileSystemEntries(String)
has the following syntax.
public static IEnumerable<string> EnumerateFileSystemEntries(
string path
)
Parameters
Directory.EnumerateFileSystemEntries(String)
has the following parameters.
path
- The directory to search.
Returns
Directory.EnumerateFileSystemEntries(String)
method returns <
Example
Returns an enumerable collection of file-system entries in a specified path.
// ww w . java 2 s . c om
using System;
using System.IO;
class Program
{
static void Main(string[] args)
{
string sourceDirectory = @"C:\current";
string archiveDirectory = @"C:\archive";
var da = Directory.EnumerateFileSystemEntries(sourceDirectory);
foreach (string currentFile in da)
{
string fileName = currentFile.Substring(sourceDirectory.Length + 1);
Directory.Move(currentFile, Path.Combine(archiveDirectory, fileName));
}
}
}