For demo purpose I have saved the latest file name in variable and printed on screen by using Console.Write() method. Using c#, we can do this task. It is very important topic for all the startup developers.

Output

In this blog, I will show you how to find the latest file or folder in particular path.
For demo purpose I have saved the latest file name in variable and printed on screen by using Console.Write() method. Using c#, we can do this task. It is very important topic for all the startup developers.

Output

Join the conversation! Your thoughts help the community grow.
Join to leave a comment
Members earn 10 SHARP for a comment, 10 SHARP for a reaction, and 250 SHARP for every blog they publish.
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegisterMembers onlyeBook · C#Modern CSharp Mastery - Advanced Guide for Experienced DevelopersDownload nowWrite a blog post and earn +250 SHARP when it is approved.
Write a blog
Jose PenaPosted Aug 10, 2018, 4:50 AM EDT
Issue: This works great with local C: drive paths and just about all network paths \\nas... However there is one path location in my network where it doesn't return the correct latest filename or modified datetime. I'm using a MessageBox to confirm latest modified datetime and file name (it gives me correct "Date" but not the correct "Time"). Why is this not working for one of my network paths? I see the latest file but C# can't see it. Essentially I'm trying to get the latest filename plus extension; store it in a string variable so SSIS package can process the latest file. -- Thank you sir.
Sheikh EmaduddinPosted Feb 26, 2018, 8:13 PM EST
Hi, Can you please tell me how to open that file?
Rathrola Prem KumarPosted Sep 7, 2016, 6:40 PM EDT
:)
SubashPosted Sep 7, 2016, 4:41 AM EDT
Intresting
Guest UserPosted Aug 14, 2016, 9:18 PM EDT
Helpful Content