private string GetPathFromProjectRoot(FileInfo file) { string path = ""; var directory = file.Directory; const int maxCount = 256; int count = 0; while (!ProjectDirectory.EndsWith(directory.Name) && count++ < maxCount) { path = Path.Combine(directory.Name, path); directory = directory.Parent; } return(path); }