How to create folders and subfolders using Rackspace cloud?

Jan 22 2013 7:40 AM
I am working on Rackspace cloud files (C#) and I have a
scenario where i need to create sub folders with in
a folder for a specified directory using .net.

Eg: c:\abc\def1\..... and c:\abc\def2\..... so on. Precisely
i need to create multiple sub folders in
a single folder . Please help me with dis...!!!

I have used following code to create folder (root folder).But How
to write the code to create subfolders?


public void CreateContainer(string ContainerName)
        {
            try
            {
                var account = new CF_Account(CFConnection, CFClient);
                var container = new CF_Container(CFConnection, CFClient, ContainerName);
                var list = account.GetContainers(true);

                var IsFound = from objList in list
                              where objList.Name == ContainerName
                              select objList;

                if (IsFound.Count() <= 0)
                {
                    account.CreateContainer(ContainerName);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


   public void SaveObjectToCloudfiles(string ContainerName, string FileName, string LocalFilePath)
        {
            try
            {
                var container = new CF_Container(CFConnection, CFClient, ContainerName);
                var obj = new CF_Object(CFConnection, container, CFClient, FileName);

                obj.WriteFromFile(LocalFilePath + @"\" + FileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


     public void CreateContainerAndSaveFiles(string ContainerName, string FileName, string LocalFilePath)
        {
            CreateContainer(ContainerName);
            SaveObjectToCloudfiles(ContainerName, FileName, LocalFilePath);
        }