问题
I have a program gets the latest version of files from a TFS server using the following code.
TeamFoundationServer myTFS = TeamFoundationServerFactory.GetServer(myURL);
VersionControlServer myVCS = (VersionControlServer)myTFS .GetService(typeof(VersionControlServer));
ItemSet downloadItems = myVCS.GetItems(myDirectory, RecursionType.Full);
foreach (Item item in downloadItems.Items)
{
item.DownloadFile(myDownloadPath);
}
Instead of getting the latest version, I would like to be able to specify a date and time, and get the ItemSet of items at that point in time. Then, on the DownloadFile call, I want to get whatever was the latest version of the files in the ItemSet at the specified date and time.
I see that Item has a CheckinDate property, but if this value is after the date and time that I am looking for, I am not sure how to get the previous version.
回答1:
When you query items with GetItems, you should provide the version spec you're interested in, in this case a DateVersionSpec.
For example:
DateTime whenever = DateTime.Now;
ItemSet downloadItems = myVCS.GetItems(myDirectory, new DateVersionSpec(whenever), RecursionType.Full);
Obviously replacing DateTime.Now with whatever you're interested in.
来源:https://stackoverflow.com/questions/15931114/versioncontrolserver-get-latest-version-of-file-at-a-specific-date-time