Dropbox - Uploading a File

Submitted by Karthikeyan on Aug 11, 2013 - 09:04
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 UploadtoDropbox { public void Upload() { CloudStorage dropBoxStorage = new CloudStorage(); var dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox); ICloudStorageAccessToken accessToken = null; using (FileStream fs = File.Open("SharpDropBox.Token", FileMode.Open, FileAccess.Read, FileShare.None)) { accessToken = dropBoxStorage.DeserializeSecurityToken(fs); } var storageToken = dropBoxStorage.Open(dropBoxConfig, accessToken); String srcFile = @"D:\statsuploader\stats.ecy"; dropBoxStorage.UploadFile(srcFile, "/"); if (dropBoxStorage.IsOpened) { dropBoxStorage.Close(); } } } }