Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8501581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:15:04+00:00 2026-06-11T01:15:04+00:00

I’m using TFS SDK and I have a method which allows to get latest

  • 0

I’m using TFS SDK and I have a method which allows to get latest versions of projects. But when I was call method, it always re-downloading files. This also takes a long time.

I tried that, I get changeSet and I compare particularly items. If item has a change, download it. But this way takes a long time too.

That is my first code without check changeSet

ItemSet items = sourceControl.GetItems(itemPath, VersionSpec.Latest, RecursionType.Full);
foreach (Item item in items.Items)
{                    
    localName = item.ServerItem.ToString();
    localName = localName.Substring(2, (localName.Length - 2)).Replace("/", "\\");

    switch (item.ItemType)
    {
        case ItemType.Any:
            throw new ArgumentOutOfRangeException("ItemType returned was Any; expected File or Folder.");
        case ItemType.File:
            item.DownloadFile("D:\\WORK\\Tries\\"+localName);
            break;
        case ItemType.Folder:
            Directory.CreateDirectory("D:\\WORK\\Tries\\"+localName);
            break;
    }
}  

And that is my new code that checking changesets

ItemSet items = sourceControl.GetItems(itemPath, VersionSpec.Latest, RecursionType.Full);

foreach (Item item in items.Items)
{                    
    localName = item.ServerItem.ToString();
    localName = localName.Substring(2, (localName.Length - 2)).Replace("/", "\\");

    var histories = sourceControl.QueryHistory(itemPath, VersionSpec.Latest, 0, RecursionType.OneLevel, null, null, null, Int32.MaxValue, true, false, true);
    bool check = false;

    foreach (Changeset history in histories)
    {
        foreach (Change change in history.Changes)
        {
            if (change.Item.Equals(item))
                check = true;
        }

    }

    switch (item.ItemType)
    {
        case ItemType.Any:
            throw new ArgumentOutOfRangeException("ItemType returned was Any; expected File or Folder.");
        case ItemType.File:
            if(check)
                item.DownloadFile("D:\\WORK\\Tries\\"+localName);
            break;
        case ItemType.Folder:
            if(!Directory.Exists("D:\\WORK\\Tries\\" + localName))
                Directory.CreateDirectory("D:\\WORK\\Tries\\"+localName);
            break;
    }
}

Does anybody have a suggestion? Thanks.

EDIT: I solved problem this way:

            String ServerFolder = itemPath; // start with "$/ + serverFolder path"
            itemPath = itemPath.Substring(2, (itemPath.Length - 2)).Replace("/", "\\");

            String LocalFolder = @"D:\WORK\"+itemPath;

            WorkingFolder workfolder = new WorkingFolder(ServerFolder, LocalFolder);
            workspace.CreateMapping(workfolder);

            workspace.Get(VersionSpec.Latest,GetOptions.Overwrite);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:15:06+00:00Added an answer on June 11, 2026 at 1:15 am

    You are actually calling the wrong method if you are trying to update your workspace to the latest changes. VersionControlServer.GetItems() is a way to ask the server to list what items it has. It will always tell you the same answer.

    If you are trying to update the items in your workspace to latest you will want to get the corresponding Workspace object and then call the “Get” method on that object. That will download the files that are out of date from the version you are requesting.

    EDIT: Adding some sample code:

    // Get a reference to our Team Foundation Server. 
    TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("http://<yourserver>:8080/tfs/<yourcollection> "));
    
    // Get a reference to Version Control. 
    VersionControlServer versionControl = tpc.GetService<VersionControlServer>();
    
    Workspace workspace = versionControl.GetWorkspace("<local path to your workspace>");
    workspace.Get();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.