Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Obtaining oldest file in a directory
Message
From
17/09/2008 18:45:15
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01348390
Message ID:
01348424
Views:
21
>>
>>If you can use Linq/lambas, you can do something like this:
>>
>>
>>System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(@"C:\");
>>System.IO.FileInfo[] files = info.GetFiles("*.jpg");
>>List<System.IO.FileInfo> sortedFiles = files.OrderBy(x => x.CreationTime).ToList();   
>>
>>
>>I don't know that internally it's any more efficient than looping, but it's definitely simple.
>
>OK, so I know you probably can't use it (sorry), but it's so cool I just had to post it. Anyway, one thing I didn't point out was that you needed to have a "using System.Linq" and, of course, a reference to the System.Core.


OK, it is cool so why can't I use it? I am going to try it. I am in 3.5 and have no problem adding the using System.Linq
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform