VersionControlServer.GetTeamProjectForServerPath Method

At the top level of the Team Foundation Server folder hierarchy are the team projects; the folders immediately below $/ in the tree. All folders and files under source control are directly or indirectly below the team projects. This function gets a specified team project.

Namespace:  Microsoft.TeamFoundation.VersionControl.Client
Assembly:  Microsoft.TeamFoundation.VersionControl.Client (in Microsoft.TeamFoundation.VersionControl.Client.dll)

public TeamProject GetTeamProjectForServerPath(
	string serverPath


Type: System.String

The server path may specify a team project directly ($/CmdLine) or any file or folder contained within a team project ($/CmdLine/parser.cs).

Either way, the team project (or top-level folder) will be returned.

Return Value

Type: Microsoft.TeamFoundation.VersionControl.Client.TeamProject
The returned TeamProject object contains the name (which may only be a substring of the string you passed in), check-in and checkout policies, and note fields for the specified team project. If no project is found, an exception occurs. You can use the TryGetTeamProjectForServerPath method to avoid this exception.


An exception is thrown if the team project does not exist in the database.

Community Additions