C# remove redundant paths from a list

Posted by andrew on Stack Overflow See other posts from Stack Overflow or by andrew
Published on 2010-06-10T09:08:02Z Indexed on 2010/06/10 9:13 UTC
Read the original article Hit count: 431

Filed under:
|
|

Say I have this list

List<string> sampleList = new List<string>
{
   "C:\\Folder1",
   "D:\\Folder2",
   "C:\\Folder1\\Folder3",
   "C:\\Folder111\\Folder4"
};

I'd like to remove the paths that are contained in other folders, for example we have C:\Folder1 and C:\Folder1\Folder3

the second entry should go away because C:\Folder1 contains C:\Folder1\Folder3

is there something that does that in the .net framework or do i have to write the algo myself?

© Stack Overflow or respective owner

Related posts about c#

Related posts about list