c# - How to find the most recent file in a directory using .NET, and without looping? -


I have to find the most recently modified file in a directory.

I know that I can loop through each file in a folder and compare File.GetLastWriteTime , but without any looping There is a better way.

How about something like this ...

  Var directory = new DirectoryInfo ("C: \\ MyDirectory"); Var myFile = (f.LastWriteTime descending selection in order from f.files (in directory) f). first (); // or ... var myFile = directory.GetFiles (). Orderbidesigning (f => f.LastWriteTime). first ();  

Comments

Popular posts from this blog

email - PHP mail error ... failed to open stream : permission denied -

c# - ListView onScroll event -

c - Linux mmap() error -