What is the C# expression to get latest text file from a folder?
give a try on:
new DirectoryInfo("C:\\MyDirectory").GetFiles().OrderByDescending(f => f.LastWriteTime).First();
Directory.GetFiles("C:\\MyDirectory","*.txt").OrderByDescending(f => new FileInfo(f).LastWriteTime).First();
Thank you peter for a quick help, but i get an error:(
some members reported similar issues (a possible relationship to infrastructure and not to code statement) when using c#- Lets take @loginerror into the loop for getting a feedback on this.
@MANISHA_V_ARORA - just checking…is ADSFilepath is a variable ? If yes , that was given inside the quotes …but it should not…please check…
Yes it is a variable, I removed the quotes too same error.
I’ve seen someone resolve a similar syntax issue by installing .NET Framework 4.8. Could you give it a try?
And also, please check all the other packages required per your Windows version here:
Thank you Maciej,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.