Hi @Mostafa Salaheldien ,
Take a look at the following example.
Dim groups = (New DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))).
GetFiles("*.rdp").GroupBy(Function(file) file.Name).Where(Function(group) group.Count() > 1)
For Each group In groups
Dim needDelete As Boolean = False
For Each file In group
' Delete all deplicate files except the first one
If needDelete Then
file.Delete()
End If
needDelete = True
Next
Next
The code will delete all the deplicate rdp files with the same name on the desktop.
Best Regards,
Xingyu Zhao
*
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.