I have a standard folder structure that i use on every project. Instead of creating them manually, I am attempting to automate this using the vault client api. What I would like to do is get a reference to the root folder "$\" and add a folder as a child. Here is the snippet of code that I have which does not work, but doesn't produce an error.
VaultClientFolder rootFolder = clientInstance.Repository.Root;
VaultClientFolder projectfolder = new VaultClientFolder();
projectfolder.Name = txtProjectName.Text.Trim();
projectfolder.Parent = rootFolder;
rootFolder.Folders.Add(projectfolder);
Any assistance on showing me where I'm wrong will be most appreciated.
Wes
Vault Client API - Adding a folder to a repository
Moderator: SourceGear
Our documentation doesn't make this clear anywhere, but all tree objects inside clientInstance.Repository.Root should be considered read-only. All modifications you want to perform to the repository should be done as a change set item, then committed to the server. The client will then automatically refresh (as part of the commit) and your changes will appear in the tree cache.
Here's some sample code (without error checking) to create a new folder. Different actions can be performed through the different ChangeSetItem_* classes.
Here's some sample code (without error checking) to create a new folder. Different actions can be performed through the different ChangeSetItem_* classes.
Code: Select all
ClientInstance ci = new ClientInstance();
ci.Init(VaultConnection.AccessLevelType.Client);
ci.Login("http://localhost/VaultService", "admin", "admin");
ci.SetActiveRepositoryID(1, "admin", "123456", true, true);
// Make a change set item that creates a new folder.
ChangeSetItem csi = new ChangeSetItem_CreateFolder(DateTime.Now, "comment", "props", "$/newfolderpath");
// Create a collection of items.
ChangeSetItemColl items = new ChangeSetItemColl();
items.Add(csi);
// Commit only this collection of items.
ci.Commit(items);
ci.Logout();
Shaw Terwilliger
SourceGear LLC
`echo sterwill5sourcegear6com | tr 56 @.`
SourceGear LLC
`echo sterwill5sourcegear6com | tr 56 @.`