public bool CompareFileContent(SystemPath other) { if (Exists == false || other.Exists == false) { return(false); } var file1 = this.AbsolutePath; var file2 = other.AbsolutePath; if (file1 == file2) { return(true); } using (var fs1 = new FileStream(file1, FileMode.Open, FileAccess.Read)) using (var fs2 = new FileStream(file2, FileMode.Open, FileAccess.Read)) { if (fs1.Length != fs2.Length) { return(false); } var file1byte = 0; var file2byte = 0; while ((file1byte == file2byte) && (file1byte != -1)) { file1byte = fs1.ReadByte(); file2byte = fs2.ReadByte(); } return((file1byte - file2byte) == 0); } }
public static SystemPath Combine(SystemPath root, params string[] parts) { return(root.IsDirectory ? Combine(root.AbsolutePath, CombinePath(false, parts)) : null); }
public string GetRelativePath(SystemPath root) { return(root == null || AbsolutePath.StartsWith(root.AbsolutePath) == false ? null : AbsolutePath.Substring(root.AbsolutePath.Length)); }