Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo checkout TFS

Tags:

c#

tfs

Is there any way to undo a checkout programmatically in C#?

The files get checked out programmatically, but if the code does not change on execution, I want the checkout to be undone.

public static void CheckOutFromTFS(string fileName)
{
    var workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(fileName);
    if (workspaceInfo == null)
        return;

    var server = new TfsTeamProjectCollection(workspaceInfo.ServerUri);
    var workspace = workspaceInfo.GetWorkspace(server);
    workspace.PendEdit(fileName);
}

The above code is my checkout code.

like image 304
Matthijs Avatar asked Feb 13 '23 11:02

Matthijs


1 Answers

You can use the Workspace.Undo method to undo the checkout.

http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.workspace.undo.aspx

like image 149
Suresh Kumar Veluswamy Avatar answered Feb 16 '23 02:02

Suresh Kumar Veluswamy