NYTom
NYTom

Reputation: 524

TFS Force Get programmatically via SDK

I can't figure out any way to force get a file from TFS programmatically. My current code:

_workspace.Get(new GetRequest(serverPath, RecursionType.None, new DateVersionSpec(dateTime)), GetOptions.Overwrite);

The above code will get a specific version, but if I manually delete the file, TFS thinks its still there. How can I use a force get for a specific version?

Upvotes: 4

Views: 1152

Answers (2)

NYTom
NYTom

Reputation: 524

I actually figured it out. The problem with using GetAll is, that it gets all and I just want one specific version of a specific file.

This is what I did:

_controlServer.GetItems(serverPath, new DateVersionSpec(dateTime), RecursionType.None).Items[0].DownloadFile(_workspace.GetWorkingFolderForServerItem(serverPath).LocalItem);

Upvotes: -1

Edward Thomson
Edward Thomson

Reputation: 78863

To do a force get, use GetOptions.GetAll. Eg:

workspace.Get(new GetRequest(serverPath, RecursionType.None, new DateVersionSpec(dateTime)), GetOptions.Overwrite | GetOptions.GetAll);

Upvotes: 5

Related Questions