Skip to main content
Home
Live to Learn!

Main navigation

  • Home
  • Learn
    • FoxPro
    • MS-DOS
    • C PRG
    • Java
    • ASP
    • Ruby on Rails
    • ASP.NET
    • E-Books
    • Exam Preparation
    • Tools
  • Blog
  • Forums
  • Contact
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Cloud API Implementation Tutorials
  3. Sharpbox API

Dropbox - Listing files

Book navigation

  • Google App Engine
  • Sharpbox API
    • Dropbox - Listing files
    • Dropbox - Uploading a File
By Karthikeyan , 6 August, 2013
Before using this code make sure you added necessary references to sharpbox dll files and you generated the token file(SharpDropBox.Token) using Dropbox Token Issuer Tool (Revised) for Sharpbox.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using AppLimit.CloudComputing.SharpBox;
using AppLimit.CloudComputing.SharpBox.StorageProvider.DropBox;

namespace StatsUploader
{
    class ListDropboxFiles
    {
        public String ListFiles()
        {
            String msg = "";
            // Creating the cloudstorage object    
            CloudStorage dropBoxStorage = new CloudStorage();
            // get the configuration for dropbox 
            var dropBoxConfig =
            CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox);
            // declare an access token 
            ICloudStorageAccessToken accessToken = null;

            // load a valid security token from file             
            using (FileStream fs = File.Open("SharpDropBox.Token", FileMode.Open, FileAccess.Read, FileShare.None))
            {
                accessToken = dropBoxStorage.DeserializeSecurityToken(fs);
            }
            // accessToken = Token;
            // open the connection  
                                    
            var storageToken = dropBoxStorage.Open(dropBoxConfig, accessToken);
                                   
            //List Files
                      
            var root = dropBoxStorage.GetRoot();
            // enumerate all child (folder and files) 
           
            if (root == null)
            {
                msg = msg + "No root object found";
            }
            else
            {
                foreach (ICloudFileSystemEntry fsentry in root)
                {
                    if (fsentry is ICloudDirectoryEntry)
                    {
                         msg = msg + fsentry.Name;
                    }
                    else
                    {
                         msg = msg + fsentry.Name;
                    }
                }
            }


            //

            // close the connection  
            dropBoxStorage.Close();
            return msg;
        }
    }
}
  • Add new comment
Tags
Dropbox API
Sharpbox
Cloud Computing

Comments

Featured Blog Posts

Convert Currency in Number to Words (Indian Rupees) - MS Excel
Foxpro Tutorial and Programs
Convert Currency in Number to Words in MS Word
Convert Currency in Number to Words (Indian Rupees) - Version 2
Best way to Use Rupee Symbol in Windows – Easy steps
Convert Currency in Number to Words - MS Access
Creating All in One Windows XP DVD with all Important Applications
RSS feed

© 2009-2025 Live to Learn.In

Terms of Use | Privacy Policy