how about using the join operator. joining on filename like this
public void cleanUp()
{
var cFiles = Directory.GetFiles(@"c:\MyData","*.*",SearchOption.AllDirectories);
var fFiles = Directory.GetFiles(@"e:\projects\massdata","*.*",SearchOption.AllDirectories);
Func<string, string, Tuple<string, long>> keySelector = (path, root) =>
new Tuple<string, long>(path.Replace(root, ""), new FileInfo(path).Length);
foreach (var file in cFiles.Join(fFiles, f => keySelector(f,@"e:\projects\massdata"), c => keySelector(c,@"c:\MyData"), (c, f) => c))
{
File.Delete(file);
}
}
Second Edit after update:
The key selector should now meet your requirement. If I've misunderstood them. It sure be rather easy so see what you need to change. If not drop a comment :)