The SharpDropBox Client automatically caches files to the IsolatedStorage for your application. It checks to see if a file has changed. If it has not since the library last got it (using the hash from the last get metadata that your app received which is in our Sterling DB Cache) and file exists in Isolated Storage, then only a quick check of the metadata will be called and no file will be downloaded (the library will point you to the local one in Isolated Storage).

Before Getting a File

Before you can get a file you should make sure that you are logged in. Please review the documentation article on Logging in.

Getting a File

Getting a file is fairly easy, simply call the library like this:
            dbxApp.GetFile("My File.txt", (localIsolatedStoragePathToFile, ex) =>
                if (ex != null)
                      // If there was any error there will be an exception coming back in the "ex" parameter
                    // "localIsolatedStoragePathToFile" contains the IsolatedStorage path to your file. 
                    // You could use our IsolatedStorage FileInfo Facade (packaged with this library) to do something like this:
                    var file = System.IO.IsolatedStorage.PSFileInfo(localIsolatedStoragePathToFile);
                       using(var strm = file.OpenText(System.IO.FileMode.Open))
                          // Read a Text File Here


There is a property of the DropBoxApp object called "MimicDropBoxFileSystemLocally" which is a boolean value. The library tries to "hide" its subdirectories from the PSDirectory/PSDirectoryInfo facades. If you don't want this to happen (maybe you sync all your files on load and just want to work locally), then you will want to have this value set to true.

The PSFile/PSFileInfo/PSDirectory/PSDirectoryInfo classes mimic the System.IO.File/FileInfo/Directory/DirectoryInfo classes. The "PS" stands for "Persisted Storage" which is one of the names that is used to refer to the IsolatedStorage mechanism. This was chosen over the "IS" prefix because any construct starting with "I" is generally expected to be an interface. To avoid confusion/conflicts, it was decided that a prefix would be helpful and avoids conflicts when both the "System.IO" and "System.IO.IsolatedStorage" namespaces are referenced via an Import/Using in the class.

Last edited Jan 19, 2011 at 10:39 AM by DevTheo, version 3


No comments yet.