title: Get Changeset of specific project of team project of team project collection
body: <p>using this : <a href="https://stackoverflow.com/questions/10249714/how-can-i-get-the-latest-change-set-number-via-tfs-api">How can I get the latest change-set number via TFS API</a></p>
  
  <p>I can only get the OLDEST changeset of a team project and using a dialog window.</p>
  
  <p>Could someone please give me an example on how to:
  - set the team project collection, team project and project programmatically?
  - get changeset of the project (not team project collection or team project changeset)?</p>
  
  <p>E.g</p>
  
  <pre><code>var TPC = &lt;NameOfTeamProjectCollection&gt;
  var TP = &lt;NameOfTeamProject&gt;
  var P = Path
  </code></pre>
  
  <p>something like </p>
  
  <pre><code>TPC = @"$/House"
  TP = @"$/Room"
  P = @"$Bed/Sheet"
  </code></pre>
  
  <p>So at the end I would get the changeset of directory <code>sheet</code> or if left out the changeset of <code>bed</code>.</p>
  
  <pre><code>public static int GetChangesetId()
  {
      TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, true);
      tpp.ShowDialog();            
  
      var tpc = tpp.SelectedTeamProjectCollection;
  
      VersionControlServer versionControl = tpc.GetService&lt;VersionControlServer&gt;();         
  
      var tp = versionControl.GetTeamProject(@"MyTeamProject");
      var path = tp.ServerItem;
  
      var q = versionControl.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full, null, VersionSpec.Latest, VersionSpec.Latest, Int32.MaxValue, true, true, false, false);
      Changeset latest = q.Cast&lt;Changeset&gt;().First();
  
      // The number of the changeset
      int id = latest.ChangesetId;
      return id;
  }
  </code></pre>
  
  <p>I tried to change <code>@"MyTeamProject"</code> to an path but it does not work. I get an error that there is no such project.</p>