I asked a question here : Clean duplicates and their instances from a list
Now I'm facing a new situation , I have a datamodel like this :
public class AmpFile
{
public string filename { get; set; }
public string actualpath { get; set; }
public int fileversion { get; set; }
}
And an example data like this :
| Index | filename | actualpath | fileversion |
|-------|-----------------|----------------------------|-------------|
| 1 | demofile.opt | d:\optfiles\demofile.opt | 8 |
| 2 | somefile.opt | c:\somefile.opt | 3 |
| 3 | somefile.opt | f:\files\somefile.opt | 8 |
| 4 | test.opt | c:\test.opt | 5 |
| 5 | demofile.opt | c:\demofile.opt | 5 |
| 6 | anothertest.opt | f:\files\anothertest.opt | 2 |
| 7 | somefile.opt | c:\somefolder\somefile.opt | 1 |
Okay now I want to find duplicates files with same name by using filename
and keep the higher version using fileversion
and delete the rest duplicates.
and by deleting I mean deleting their files and from list too.
I tried to figure it out by linq but every harder i try i get more worse results , I need to do this carefully and clean , that's why I'm asking on stackoverflow , to find the best solution.
regards.