VersionControlServer - 在特定日期/时间获取文件的最新版本

jkh*_*jkh 0 c# version-control tfs timestamp download

我有一个程序使用以下代码从TFS服务器获取最新版本的文件.

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);
}
Run Code Online (Sandbox Code Playgroud)

我希望能够指定日期和时间,并在该时间点获取项目的ItemSet,而不是获取最新版本.然后,在DownloadFile调用中,我想在指定的日期和时间获取ItemSet中文件的最新版本.

我看到Item有一个CheckinDate属性,但是如果这个值在我要查找的日期和时间之后,我不知道如何获得以前的版本.

Edw*_*son 5

当您使用查询项目时GetItems,您应该提供您感兴趣的版本规范,在本例中为a DateVersionSpec.

例如:

DateTime whenever = DateTime.Now;
ItemSet downloadItems = myVCS.GetItems(myDirectory, new DateVersionSpec(whenever), RecursionType.Full);
Run Code Online (Sandbox Code Playgroud)

显然要替换DateTime.Now你感兴趣的东西.