Find Files That Match a Wildcard Expression - CSharp File IO

CSharp examples for File IO:Directory

Description

Find Files That Match a Wildcard Expression

Demo Code


using System;//  w ww . j  a  v a 2 s.  co m
using System.IO;

    static class MainClass
    {
        static void Main(string[] args)
        {

            DirectoryInfo dir = new DirectoryInfo("c:/a/");
            FileInfo[] files = dir.GetFiles("*.cs");

            foreach (FileInfo file in files)
            {
                Console.Write("Name: " + file.Name + "  ");
                Console.WriteLine("Size: " + file.Length.ToString());
            }

        }
    }

Result


Related Tutorials