你可以使用TFS API来实现你想要的。获取所有文件,文件夹并获取他们的目录。判断文件是否正在等待更改。然后使用您的脚本将文件复制到备份位置。
工作区,你的代码中引用:
private void PopulateTreeView(string workspaceName)
{
// Connect to TFS - VersionControlServer Service
var tfs =
TfsTeamProjectCollectionFactory.GetTeamProjectCollection
(new Uri("https://tfs2010:8080/defaultcollection"));
var vcs = tfs.GetService<VersionControlServer>();
// Get the workspace the user has currently selected
var workspace = vcs.QueryWorkspaces(workspaceName,
vcs.AuthorizedUser, Environment.MachineName)[0];
_workspace = workspace;
tvWksNavigator.Nodes.Clear();
// Loop through all folders and get directories and files
foreach (var folder in workspace.Folders)
{
var info = new DirectoryInfo(folder.LocalItem);
if (info.Exists)
{
var rootNode = new TreeNode(info.Name) { Tag = info };
GetDirectories(info.GetDirectories(), rootNode);
tvWksNavigator.Nodes.Add(rootNode);
}
}
}
使用方法QueryPendingChanges,它可能通过一个文件路径,看看文件被挂起的更改,如果是这样,什么是锁类型,也可以获取该文件的下载详细信息。
var status = _workspace.QueryPendingSets(new[] { new ItemSpec(
dir.FullName,
RecursionType.None) },
_workspace.Name, vcs.AuthorizedUser,
false);
这是TFVC,但不是Git ... –