Use file filer on a directory in CSharp

Description

The following code shows how to use file filer on a directory.

Example


   //w w w  . j av  a2s . c o  m

using System;
using System.IO;

static class MainClass
{
    static void Main(string[] args)
    {
        DirectoryInfo dir = new DirectoryInfo("c:\\a");
        FileInfo[] files = dir.GetFiles("*.gif");

        // Display the name of all the files.
        foreach (FileInfo file in files)
        {
            Console.Write("Name: " + file.Name + "  ");
            Console.WriteLine("Size: " + file.Length.ToString());
        }

    }
}




















Home »
  C# Tutorial »
    IO »




File Attribute
File Security
Directory Attribute
Directory Recursive
Binary File
Text Field
Buffered IO
Create Copy Delete Move
CSV
Drive
File System Watcher
Isolated Storage
MemoryStream
Serialize
Zip