c# - using linq to select last written file -


I want to get the latest written files from a directory and their extension.

The file that can be present in the directory (with their creation date):

  2009-10-20T07: 00: 00.000 filename1.mp4 2009-10-20T07 : 00: 01.000 filename1_0.mp4 2009- 10-20 -07: 00: 02.000 Filename 1_1.mp4 2009-10-20 -07: 00: 00.000 Filename 1.wmv 2009-10-20007: 10: 00.000 Filename 2.mp4 2009-10-20T07: 10: 00.000 Filename 2. VMV  

Note that the filename 'filename1' has 3 versions serially counted in the mp4 format. I'm looking for files named 'filename1' to get the following results (not in any particular order):

  filename1_1.mp4 filename1.wmv  
< P> Because these files have been made to the latest with two extensions but both have the filename, 'filename1', I wish. GetLatestFiles ("c: \\ test \\", in "GetInst Fi"

 Filename1 ")) {Console.WriteLine (fi.Name); } // ... public static IEnumerable & lt; FileInfo & gt; GetLatestFiles (String Path, String BaseName) {Go to New DirectoryInfo (Path) .GetFiles (baseName + "*. *") .GroupBy (f => f.Extension) Select (g = & gt; g.OrderByDescending (f = & gt; f.LastWriteTime). First ()); }  

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -