This project is read-only.
Create new Directory in the root of the cloud storage

Availability: SharpBox 0.9

The following example shows how to create a new directory in the root of an existing cloud storage. This example uses the implemented drop box storage provider, so it needs also a valid dropbox configuration. To get the sample up and running an own dropbox account is neccessary. Additionally a valid application key and secret is needed. If you don't have one, use our test-application.
        static void CreateDirectory()
        {
            // instanciate a new credentials object, e.g. for dropbox
            DropBox.DropBoxCredentials credentials = new AppLimit.CloudComputing.SharpBox.DropBox.DropBoxCredentials();

            // attach the application information 
            credentials.ConsumerKey = "TheApplicationKey";
            credentials.ComsumerSecret = "TheApplicationSecret";

            // add the account information
            credentials.UserName = "myaccount@dropbox.com";
            credentials.Password = "mypassword";
            
            // instanciate a cloud storage configuration, e.g. for dropbox
            DropBox.DropBoxConfiguration configuration = DropBox.DropBoxConfiguration.GetStandardConfiguration();

            // instanciate the cloudstorage manager
            CloudStorage storage = new CloudStorage();

            // open the connection to the storage
            storage.Open(configuration, credentials);            

            // create the folder in the root directory
            ICloudDirectoryEntry newFolder = storage.CreateFolder("MyFirstFolder", null);
            if (newFolder == null)
            {
                Console.WriteLine("Couldn't create MyFirstFolder");
            }

            // close the cloud storage connection
            if (storage.IsOpened)
            {
                storage.Close();
            }
        }

Last edited Aug 6, 2011 at 6:36 AM by dei79, version 3

Comments

djthevj Mar 8, 2011 at 12:26 PM 
Hi,

I am trying to use the above code in my application . However, i got an error after it instantiate the cloud storage object and try to use the Open method.

Here is the code snippet

// instanciate the cloudstorage manager
AppLimit.CloudComputing.SharpBox.CloudStorage storage = new AppLimit.CloudComputing.SharpBox.CloudStorage();

try
{
AppLimit.CloudComputing.SharpBox.ICloudStorageAccessToken p1 = storage.Open(configuration, credentials);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}.

The catch block says the exception as "Unhandled Exception . I tried to add the Cloudstorage files to my project but seems to be lot of dependent files needs to be added .Is there any quick way through way i can check it or am i missing anything.

Appreciate your inputs.

sanaanicolas Nov 21, 2010 at 7:49 AM 
hi ya still the same problem because i was working on version 1.0.2,
thanks i will download the newest version

Renald Nov 15, 2010 at 11:58 PM 
Hi,
I have make some test with the next version of SharpBox 1.0.3 and don't reproduce your problem.
Do you still have problem?
Renald

sanaanicolas Nov 14, 2010 at 2:17 PM 
what about creating folder in the same name , it doesn't return exception but also it doesn't add it to the folder list , so anyone notice that, did u solve it
dropbox add folders in the same name but add to it 1,2....
anyway i'll try to process that in my code