Discuss this help topic in SecureBlackbox Forum

Clouds: Get directory structure and file list

First you need to obtain the object, that corresponds to the account's root folder. To do this call TElBoxDataStorage.AcquireFolder() method and pass it the empty string. The method will return the instance of TElBoxFolder class. Call the methods of the object, returned by AcquireFolder, to perform operations with files and folders, located in account's root folder. When the object is not needed anymore, call its Release() method.


TElBoxFolder root = storage.AcquireFolder("");
Console.WriteLine("Root folder: {0} (size = {1})", root.Name, root.Size);

When you have an object for any folder, you can list the files and folders, contained in this folder. To do this call TElBoxFolder.List() method. This method accepts an instance of TElDataStorageObjectList and stores there the results of the listing as instances of TElBoxFolder and TElBoxFile classes (both are the descendants of TElBoxDataStorageObject) for each folder and file, found in the folder, for which List() method was called. The objects are owned by the list object.

Note that the list, passed to List() method, is not cleared automatically by the method, and new objects are added to the ones, already present in the list.

Also it is important, that when the list is disposed of, all contained objects are also disposed. If you need to work with some object later, you need to make a copy of it and use the copy.


TElDataStorageObjectList list = new TElDataStorageObjectList();

// get all the objects in the root folder

Console.WriteLine("Listed {0} objects", list.Count);
for (int i = 0; i < list.Count; i++)
    TElBoxDataStorageObject obj = list.get_Objects(i) as TElBoxDataStorageObject;
    Console.WriteLine(" - {0} (id = {1}, size = {2})", obj.Name, obj.ID, obj.Size);

It's possible to store not the folder or file object itself, but its ID on the server. When it's necessary to perform some operation with the file or folder, for which the ID is known, you can acquire the object using TElBoxDataStorage.AcquireFile() or AcquireFolder() method and pass the known ID to this method.

Besides regular folders there exists a special folder called Trash. All files and folders, which are deleted, are moved to Trash and stay there for some time (by default it's 30 days since deletion), after which the deleted files and folders are deleted completely. To retrieve the list of files and folders in Trash call TElBoxDataStorage.ListTrashed(). It works in the same way as List() method, but returns objects, stored in Trash.

How To articles about Box.com cloud

Discuss this help topic in SecureBlackbox Forum