Folder Creation Half Working

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

Moderator: SourceGear


Posts: 4
Joined: Fri Jan 04, 2013 9:08 am
PostPosted: Mon Jan 21, 2013 9:26 am
c#
Using the following to auto create a folder structure but it's only creating the following.
It also adds my text file to the description folder.
No errors.

    ClientName
    -ProjectName
    --Trunk
    ---Description

Code: Select all
if (ServerOperations.isConnected())
                {
                    VaultClientFolder folder = ServerOperations.ProcessCommandListFolder("$/", false);

                    bool hasFolder = false;

                    foreach(VaultClientFolder dir in folder.Folders)
                    {
                        if (dir.Name == clientName)
                        {
                            hasFolder = true;
                            break;
                        }
                    }
                    if (!hasFolder)
                    {
                        ServerOperations.ProcessCommandCreateFolder("$/" + clientName + "/" + projectName);
                        ServerOperations.ProcessCommandCreateFolder("$/" + clientName + "/" + projectName + "/Release");
                        ServerOperations.ProcessCommandCreateFolder("$/" + clientName + "/" + projectName + "/Trunk");
                        ServerOperations.ProcessCommandCreateFolder("$/" + clientName + "/" + projectName + "/Trunk/Description");
                        ServerOperations.ProcessCommandCreateFolder("$/" + clientName + "/" + projectName + "/Trunk/Discovery");
                        ServerOperations.ProcessCommandCreateFolder("$/" + clientName + "/" + projectName + "/Trunk/Tools");
                        ServerOperations.ProcessCommandCreateFolder("$/" + clientName + "/" + projectName + "/Trunk/Dependencies");

                        string descript = Directory.GetCurrentDirectory() + "\\Description.txt";
                        if (File.Exists(descript))
                        {
                            File.Delete(descript);
                        }
                        using (StreamWriter sw = File.CreateText(descript))
                        {
                        }

                        ServerOperations.client.AutoCommit = true;
                        ServerOperations.ProcessCommandAdd("$/" + clientName + "/" + projectName + "/Trunk/Description", new string[] { descript });

                        return true;
                    }
                    else
                    {
                        throw new ArgumentException("Project Base Folder Already Exists");
                    }
                }
                else
                {
                    throw new ArgumentException("Could not login to Vault Server");
                }

Posts: 4
Joined: Fri Jan 04, 2013 9:08 am
PostPosted: Mon Jan 21, 2013 11:37 am
I have fixed the issue

All I did was move
Code: Select all
ServerOperations.client.AutoCommit = true;

to the top of the code.

Posts: 8449
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
PostPosted: Mon Jan 21, 2013 11:40 am
Thanks for the update.
Beth Kieler
SourceGear Technical Support

Return to Questions (API)

Who is online

Users browsing this forum: No registered users and 1 guest

cron