C# Treeview vault folders

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
Ton Blokhuizen
Posts: 2
Joined: Wed Dec 07, 2011 5:07 am

C# Treeview vault folders

Post by Ton Blokhuizen » Wed Dec 07, 2011 5:50 am

I'm trying to create a C# userform with a Treeview on it.
What I would like to do is show the repository tree with folders (and files) just like the Vault client interface.

For some reason I'm not able to generate usable data for the treeview.

The things i have tried are:

Note that my application does not require to have a local working folder.
I'ts just a representation of the directory structure of the repository database.

The only thing I have accompiced is the use of the XMLHelper.
Like so: (following example found on this forum, used for listing Checkouts to XMl structure)

Code: Select all

VaultClientCheckOutList coList = ServerOperations.ProcessCommandListCheckOuts();
                

                // output the checkout list
                StringWriter sw = new StringWriter();
                System.Xml.XmlTextWriter xml = new XmlTextWriter(sw);
                xml.Formatting = System.Xml.Formatting.Indented;
                xml.WriteStartElement("root");

                xml.WriteStartElement("ListCheckOuts");
                XmlHelper.XmlOutput(xml, coList);
                xml.WriteEndElement();
I've tried using the ServerOperations.ProcessCommandListFolder But to retrieve any usable data you must pass it trough the XMLHelper.

I would like to have a simple collection or array containing just the folder and files, so i can pass it to my treeview control.

Any help is appreciated

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: C# Treeview vault folders

Post by Beth » Wed Dec 07, 2011 3:46 pm

If you look at the thread here: http://support.sourcegear.com/viewtopic.php?f=31&t=8020, there's a good example in the post made by icnocop in the middle of the thread. You should be able to push each piece into your array as you go through it.


private void GetOldAndMissing(string path)
{
VaultClientFolder folder = ServerOperations.ProcessCommandListFolder(path, true);
//push folder to your array

foreach (VaultClientFile file in folder.Files)
{
//push the files to your array
}

foreach (VaultClientFolder subfolder in folder.Folders)
{
GetOldAndMissing(subfolder.FullPath);
}
}
Beth Kieler
SourceGear Technical Support

Ton Blokhuizen
Posts: 2
Joined: Wed Dec 07, 2011 5:07 am

Re: C# Treeview vault folders

Post by Ton Blokhuizen » Thu Dec 08, 2011 2:52 am

Thanx, this does the trick !
Very nice.

I was looking for a more detailed set of documantation regarding the usage of the API, but could not find any buth the helpfile shipped with the dsk.
Is there more documentation available ?

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: C# Treeview vault folders

Post by Beth » Thu Dec 08, 2011 11:20 am

The client API should have a .chm file in the .zip file you downloaded.

All additional API help is in the Development Tips of the forum.
Beth Kieler
SourceGear Technical Support

dellmerca
Posts: 1
Joined: Mon Feb 20, 2012 11:04 am

Re: C# Treeview vault folders

Post by dellmerca » Mon Feb 20, 2012 11:07 am

find here a simple C# treeviewer

http://csharp.net-informations.com/gui/cs-treeview.htm

dell.

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: C# Treeview vault folders

Post by Beth » Tue Feb 21, 2012 5:20 pm

Thank you for providing the additional information.
Beth Kieler
SourceGear Technical Support

Post Reply