Discuss this help topic in SecureBlackbox Forum

Clouds: Delete folder

To delete a folder use one of two Delete() methods:

  1. The first, Delete() without parameters, is the method of TElBoxDataStorageObject (the ancestor of TElBoxFolder class). It deletes both files and folders, but only empty folders can be deleted this way. If the folder is not empty, EElBoxServerError with "folder_not_empty" in its Code property, will be thrown.

    C#:

    
    TElBoxFolder emptyFolder = storage.AcquireFolder(@"...");
    Console.WriteLine("Folder: {0} (id = {1}, size = {2})",
                      emptyFolder.Name, emptyFolder.ID, emptyFolder.Size);
    emptyFolder.Delete();
    

  2. The second, Delete() with Recursive parameter, is the method of TElBoxFolder class. If the value of Recursive parameter is false, then the method acts in the same way as the first variant. If the value of Recursive parameter is true, the method removes all folder contents and the folder itself.

    C#:

    
    TElBoxFolder nonEmptyFolder = storage.AcquireFolder(@"...");
    Console.WriteLine("Folder: {0} (id = {1}, size = {2})",
                      nonEmptyFolder.Name, nonEmptyFolder.ID, nonEmptyFolder.Size);
    nonEmptyFolder.Delete(true);
    
    

As a result of successful execution of Delete() method the folder on the server will be moved to Trash, and the TElBoxFolder object will be destroyed, which means that after deletion of the folder you should not access properties or use methods of the object.

The attempt to call TElBoxDataStorage.AcquireFolder() with the ID of the deleted folder will cause EElBoxServerError exception with "trashed" code.

To obtain the object for the deleted folder call TElBoxDataStorage.AcquireTrashedFolder() method.

How To articles about Box.com cloud

Discuss this help topic in SecureBlackbox Forum