If you are using Client Object Model Reference to manage the Version Control programmatically.
To create a branch, you need to use the "CreateBranch()" method in Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer class.
Creates a branch on the server and checks it in without downloading
the branch to the client.
A sample for you reference:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.TeamFoundation.Client;
using System.Net;
namespace Model.versionControl
{
public static class CreateBranch
{
public static void CreateBranchWithComment()
{
NetworkCredential cre = new NetworkCredential("userName", "password", "domain");
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("http://TFSServerName:8080/tfs/CollectionName"), cre);
VersionControlServer vcServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
int changesetId = vcServer.CreateBranch(@"$/SourceControl/WebSites", "$/SourceControl/WebSites_Branch", VersionSpec.Latest);
new WorkspaceVersionSpec("machineName","domain\userName");
Changeset changeset = vcServer.GetChangeset(changesetId);
changeset.Update();
}
}
}
You could also take a look at this similar question: How to create a new source code branch using TFS API?
As for renaming a file or directory, you could use Workspace.PendRename Method
, sample code please refer: How do I move a TFS file with c# API?