コード例 #1
0
        public static DropboxInfo RetrieveDropboxInfo(string filename)
        {
            LOG.InfoFormat("Retrieving Dropbox info for {0}", filename);

            DropboxInfo dropBoxInfo = new DropboxInfo();

            dropBoxInfo.ID = filename;
            dropBoxInfo.Title = filename;
            dropBoxInfo.Timestamp = DateTime.Now;
            dropBoxInfo.WebUrl = string.Empty;

            // get the config of dropbox
            Dropbox.DropBoxConfiguration dropBoxConfig =
            CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) as
            Dropbox.DropBoxConfiguration;

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

            // get the root entry of the cloud storage
            ICloudDirectoryEntry root = storage.GetRoot();

            // open the connection to the storage
            storage.Open(dropBoxConfig, config.DropboxAccessToken);
            dropBoxInfo.WebUrl = storage.GetFileSystemObjectUrl(dropBoxInfo.ID, root).ToString();

            ICloudFileSystemEntry fileSystemEntry = storage.GetFileSystemObject(dropBoxInfo.ID, root);
            if (fileSystemEntry != null)
            {
                dropBoxInfo.Title = fileSystemEntry.Name;
                dropBoxInfo.Timestamp = fileSystemEntry.Modified;
            }

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

            return dropBoxInfo;
        }