C#LINQProgramming

C# LINQ to query a directory

I like introduce the easiness of using LINQ with C# on query of a directory, and how short the code could be. Before we will need to long line of code to complete this task, but LINQ came along in C# 3.0, has short and simplify the process alot. Also when querying the directory, you can even dig out only the name of the file, or the full path if you like. Here let have a look at the code; 

//======================================
// Developed by Sarin Na Wangkanai,
// Copyright 2008, All rights reserved
//======================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CSharp1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Path for file to query from
            string Path = @"d:\Documents\Visual Studio 2008\Projects\CSharp1\CSharp1\files";

            var FileQuery = from c in new DirectoryInfo(Path).GetFiles("*.*")
                            select new { c.Name, c.FullName };

            foreach (var q in FileQuery)
            {
                Console.WriteLine(q.Name);
            }
            Console.ReadKey(true);

        }
    }
}