Udostępnij za pośrednictwem


How to: Tell if files are identical using TFS APIs?

In a previous post, I answered this question using Diff APIs, which will require the items to be downloaded first. Here's a faster way to do it (thanks to MichalMa):

Use GetItem or GetItems method to get the Item objects for the files. If ContentLength and HashValue for the items match, and HashValue is not null, then items should be identical. You can do the same check with PendingChange.HashValue too to compare local files that have pending changes. Note that HashValue is the MD5 HashValue for the contents of the file, and it's been shown that it's not collision resistant although it's extremely rare to see such collisions.