Directory.GetFiles in date order


how go getfiles or getsystemfile in date order? need other methods, or need set something?

thanks,


jon jacobs
message composed entirely recycled electrons.

this should work, though when tested .txt files creation date became creation date of folder in. if created a word document, creation date correct , code worked.

    class program
    {
        static void main(string[] args)
        {
            directoryinfo dirinfo = new directoryinfo(@"c:\test\");

            var filesinorder = f in dirinfo.enumeratefiles()
                               orderby f.creationtime
                               select f;

            foreach (var item in filesinorder)
            {
                console.writeline(item.name);
            }

            console.readkey();
        }
    }


bob - www.crowcoder.com


Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

SQL Server 2008 - High Memory Usage

How to send non-standard Content-Type header ?