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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With