Select Distinct Fileinfo Lastwritetime in format dd.MM.yyyy from files in folder

Hi,
i want to get the unique last write date of files in folder.

In this example the result should be “28.04.2024” and “29.04.2024” in an array-variable.

28.04.2024 04:37 440 05-30–4-28-2024_SUService.log
28.04.2024 21:51 440 05-30–4-29-2024_SUService.log
28.04.2024 05:31 440 21-30–4-28-2024_SUService.log
29.04.2024 21:52 440 05-30–4-30-2024_SUService.log
29.04.2024 05:31 440 21-30–4-29-2024_SUService.log

can you please confirm

using info from filename
OR
FileInfo Property e.g. LastWrite…

Unbenannt
I don’t understand the difference.
Just the creation time or last write time from the file but only the date in specific format, because i need this value for type into.

Hi @gerhard.reisinger

Try the below syntax:

uniqueDates = Directory.GetFiles("C:\Your\Folder\Path").Select(Function(file) System.IO.File.GetLastWriteTime(file).ToString("dd.MM.yyyy")).Distinct().ToArray()

Pass your Folder path and uniqueDates is of DataType Array(System.String)

Regards

macht schon sinn ein bisschen genauer draufzuschauen.
Ok nicht die Angabe vom Dateinamen, sondern eines der technischen Eigenschaften sollen herangezogen werden

denken aber auch dass beide Dateien nicht in der gleichen Sekunde angefasst wurden. Nehmen somit an, dass es der Tag ohne Zeit information sein sollte

So we can do

  • Select the Dates without the time portion and Distinct it with LINQ Operator

Assign Activity
arrDistinctDate | String Array =

(From fi in new DirectoryInfo("YourPath").GetFiles()
Let ds = fi.LastWriteTime.Date
Order by ds
Select v=ds.ToString("dd.MM.yyyy")).Distinct().toArray

It works fine, thank you very much!

@gerhard.reisinger
Perfect, so the topic can be closed by
Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.