如何在TFS中解锁文件?

时间:2011-04-12 13:22:27

标签: c# tfs

如何在TFS中解锁文件?它永远不会进入foreach循环。为什么?本地路径和服务器路径为true:

static void UnlockFiles(string[] localPaths)
{
    var serverPaths = GetServerPaths(localPaths);
    var pendingSets = _sourceControl.QueryPendingSets(serverPaths, RecursionType.Full, null, null);

    foreach (var pendingSet in pendingSets)
        UnlockItemsFromPendingSet(serverPaths, pendingSet);
}

static void UnlockItemsFromPendingSet(string[] serverPaths, PendingSet pendingSet)
{
    foreach (var change in pendingSet.PendingChanges)
    {
        if (serverPaths.Contains(change.ServerItem.ToLower()))
        {
            var ws = _sourceControl.GetWorkspace(pendingSet.Computer, pendingSet.OwnerName);

            if (ws.SetLock(change.ServerItem, LockLevel.None) > 0)
                Console.WriteLine("Lock unset on {0}", change.ServerItem);
        }
    }
}

0 个答案:

没有答案