public static string ChangeRoot(string file, string oldRootDir, string newRootDir = null) { if (oldRootDir != null) { oldRootDir = StringTools.PathFltr(oldRootDir + '\\'); if (StringTools.StartsWith(file, oldRootDir, true) == false) { throw new Exception("Wrong oldRootDir: " + oldRootDir + ", " + file); } file = file.Substring(oldRootDir.Length); } if (newRootDir != null) { file = StringTools.Combine(newRootDir, file); } return(file); }