4

I am trying to use the TFS API to retrieve the latest code from the server within a workspace. I found this question:

How do you get the latest version of source code using the Team Foundation Server SDK?

Which is essentially what I want to do; however, I want to use an existing workspace, and only retrieve a certain section of the code. Is this possible?

For example (using the example given in the above question):

workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite, "$/MyFolder/MyProject");

Is something like this possible without setting up a new workspace or something?

Community
  • 1
  • 1
Paul Michaels
  • 16,185
  • 43
  • 146
  • 269
  • Please do not use GetAll and Overwrite unless you really need to - they add quite a bit of unnecessary processing overhead to the server and client, as well as network overhead. – Edward Thomson Dec 01 '11 at 15:08
  • I absolutely do need to, because the point of the program is to retrieve all the latest source code (within the specified sub-directory) to the client PC. It should be an infrequent process though. – Paul Michaels Dec 05 '11 at 20:04
  • 2
    Right, my point is that the server is smart enough to give you the latest source code without force or overwrite flags, unless you've done something horrible to your workspace. – Edward Thomson Dec 05 '11 at 20:18

1 Answers1

5

You need to gain access to your workspace with something like this:

var vcServer = teamProjectCollection.GetService<VersionControlServer>();
Workspace myWorkspace = vcServer.GetWorkspace("workspaceName", "workspaceOwner");

Then you get latest with a

 myWorkspace.Get();

or refine what you want get by consulting this.

In order to find out about your workspace(s) details navigate in VS to

"File" > "Source Control" > "Workspaces..."

pantelif
  • 8,524
  • 2
  • 33
  • 48