Delete a file or directory in a simple way

Availability: SharpBox 1.0.3

The following example shows how to delete a file or a directory of an existing cloud storage with the help of the existing comfort functions.

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 DeleteFileSystemEntrySimple()
        {
            // 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.ConsumerSecret = "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);           

            // delete a file
            storage.DeleteFileSystemEntry("/Public/My/File.sample");
			
            // delete a directory
            storage.DeleteFileSystemEntry("/Public/My/Directory");
            
            // close the cloud storage connection
            if (storage.IsOpened)
            {
                storage.Close();
            }
        }

Last edited Nov 15, 2010 at 9:47 PM by Renald, version 1

Comments

No comments yet.