你可以使用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 ... –