【问题标题】:VersionControlServer - Get latest version of file at a specific date/timeVersionControlServer - 在特定日期/时间获取最新版本的文件
【发布时间】:2013-04-10 16:13:50
【问题描述】:

我有一个程序使用以下代码从 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);
}

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

我看到 Item 有一个 CheckinDate 属性,但如果这个值在我要查找的日期和时间之后,我不确定如何获取以前的版本。

【问题讨论】:

    标签: c# version-control tfs download timestamp


    【解决方案1】:

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

    例如:

    DateTime whenever = DateTime.Now;
    ItemSet downloadItems = myVCS.GetItems(myDirectory, new DateVersionSpec(whenever), RecursionType.Full);
    

    显然将DateTime.Now 替换为您感兴趣的任何内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-06
      • 2021-11-08
      • 2020-11-25
      • 2016-10-02
      • 1970-01-01
      • 2018-02-13
      相关资源
      最近更新 更多