C# TFS Set Latest Information of File programmatically?

202 Views Asked by At

I wrote an Visual Studio Extension for our Company, which gets the Specific Version of Files in a Solution based on Microsoft TFS. We use Visual Studio 2015 / 2019.

My question is, is there some way to set the "Latest" Information of an File which gets displayed in the Source Control Explorer programmatically?

Like this: Latest Information Visual Studio

So i have a list with all files which i want to get. Before i used this method to get for every file:

WorkspaceInfo workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(filePath);
Workspace ws = workspaceInfo.GetWorkspace(new TfsTeamProjectCollection(workspaceInfo.ServerUri));

status = ws.Get(new GetRequest(new ItemSpec(filePath, RecursionType.Full), VersionSpec.Latest), GetOptions.GetAll);

This worked fine and refreshed the latest information. Sadly this method is to slow compared to the "real" Get Specific Version from Visual Studio.

Now I tried this method, which is much faster, but doesn´t change the latest information of the file:

item.DownloadFile(filePath);

Even if I downloaded the file (I checked the differences between changesets) and got the latest version of it, the information in Source Control Explorer keeps saying "No".

Does someone know a solution for this, or even a better solution?

1

There are 1 best solutions below

0
On

Why you don't use the VersionControlServer.DownloadFile instead the item.downloadfile? https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/bb138622(v%3Dvs.110)