public async Task <FileSystemInfo> moveAsync(DropboxApi api, string nameOld, string nameNew) { FileSystemInfo folder = await api.MoveAsync("dropbox", "/" + nameOld.Replace('\\', '/'), "/" + nameNew.Replace('\\', '/')); //FileSystemInfo folder = await api.CreateFolderAsync("dropbox", "/" + name.Replace('\\', '/')); return(folder); }
public String TestUploadFiles() { Console.WriteLine("Attempting to get access token before uploading the file"); //Your access token: 6on3pwn3smj94m4 //Your access secret: tj4429nmp6nc9af var accessToken = new OAuthToken("6on3pwn3smj94m4", "tj4429nmp6nc9af"); var api = new DropboxApi(ConsumerKey, ConsumerSecret, accessToken); var file = api.UploadFile("dropbox", "TargetFileName.ext", @"test.txt"); var account = api.GetAccountInfo(); Console.WriteLine(account.DisplayName); Console.WriteLine(account.Email); var total = account.Quota.Total / (1024 * 1024); var used = (account.Quota.Normal + account.Quota.Shared) / (1024 * 1024); Console.WriteLine(String.Format("Dropbox: {0}/{1} Mb used", used, total)); Console.WriteLine(string.Format("{0} uploaded.", file.Path)); Console.WriteLine(); Console.WriteLine("Done. Press any key to continue..."); Console.Read(); return String.Format("{0}/{1} Mb used", used, total); }
public FileSystemInfo addFile(DropboxApi api, string name, string path) { string pathServer = "dropbox"; if (name.LastIndexOf('\\') != -1) { pathServer += "/" + name.Substring(0, name.LastIndexOf('\\')); name = path.Split('\\').Last(); } return(api.UploadFile(pathServer, name, path)); }
public async Task <FileSystemInfo> addFileAsync(DropboxApi api, string name, string path) { string pathServer = "auto"; if (name.LastIndexOf('\\') != -1) { pathServer += "/" + name.Substring(0, name.LastIndexOf('\\')); name = path.Split('\\').Last(); } FileSystemInfo file = await api.UploadFileAsync(pathServer, name, path); return(file); }
static void Main() { // Uncomment the following line or manually provide a valid token so that you // don't have to go through the authorization process each time. var accessToken = GetAccessToken(); //var accessToken = new OAuthToken("token", "secret"); var api = new DropboxApi(ConsumerKey, ConsumerSecret, accessToken); var account = api.GetAccountInfo(); Console.WriteLine(account.DisplayName); Console.WriteLine(account.Email); var total = account.Quota.Total / (1024 * 1024); var used = (account.Quota.Normal + account.Quota.Shared) / (1024 * 1024); Console.WriteLine(String.Format("Dropbox: {0}/{1} Mb used", used, total)); Console.WriteLine(); var publicFolder = api.GetFiles("dropbox", "Public"); foreach (var file in publicFolder.Contents) { Console.WriteLine(file.Path); } // Create a folder var folder = api.CreateFolder("dropbox", "/test"); Console.WriteLine("Folder created."); Console.WriteLine(String.Format("Root: {0}", folder.Root)); Console.WriteLine(String.Format("Path: {0}", folder.Path)); Console.WriteLine(String.Format("Modified: {0}", folder.Modified)); // Move a folder folder = api.Move("dropbox", "/test", "/temp"); // Delete a folder folder = api.Delete("dropbox", "/temp"); // Download a File var fileDownload = api.DownloadFile("dropbox", "Public/YourFileName.ext"); fileDownload.Save(@"D:\YourFileName.ext"); // Upload a File var fileUpload = api.UploadFile("dropbox", "TargetFileName.ext", @"YourFilesLocation"); Console.WriteLine(string.Format("{0} uploaded.", fileUpload.Path)); Console.WriteLine(); Console.WriteLine("Done. Press any key to continue..."); Console.ReadKey(); }
public static void Main() { // Uncomment the following line or manually provide a valid token so that you // don't have to go through the authorization process each time. // var accessToken = GetAccessToken(); //Your access token: 6on3pwn3smj94m4 //Your access secret: tj4429nmp6nc9af var accessToken = new OAuthToken("6on3pwn3smj94m4", "tj4429nmp6nc9af"); var api = new DropboxApi(ConsumerKey, ConsumerSecret, accessToken); var file = api.UploadFile("dropbox", "TargetFileName.ext", @"test.txt"); Console.WriteLine(string.Format("{0} uploaded.", file.Path)); Console.WriteLine(); Console.WriteLine("Done. Press any key to continue..."); Console.ReadKey(); }
public Account getDropboxAccount() { Console.WriteLine("Attempting to get access token before uploading the file"); //Your access token: 6on3pwn3smj94m4 //Your access secret: tj4429nmp6nc9af var accessToken = new OAuthToken("6on3pwn3smj94m4", "tj4429nmp6nc9af"); var api = new DropboxApi(ConsumerKey, ConsumerSecret, accessToken); var account = api.GetAccountInfo(); Console.WriteLine(account.DisplayName); Console.WriteLine(account.Email); var total = account.Quota.Total / (1024 * 1024); var used = (account.Quota.Normal + account.Quota.Shared) / (1024 * 1024); Console.WriteLine(String.Format("Dropbox: {0}/{1} Mb used", used, total)); return account; }
public async Task <File> viewFilesAsync(DropboxApi api, string name) { File file = await api.GetFilesAsync("auto", name); return(file); }
public File viewFiles(DropboxApi api, string name) { return(api.GetFiles("dropbox", name)); }
public FileSystemInfo downloadFile(DropboxApi api, string name) { return(api.DownloadFile("dropbox", name)); }
public async Task <Account> getInfoAccountAsync(DropboxApi api) { Account account = await api.GetAccountInfoAsync(); return(account); }
public FileSystemInfo delete(DropboxApi api, string name) { return(api.Delete("dropbox", "/" + name.Replace('\\', '/'))); }
public FileSystemInfo createFolder(DropboxApi api, string name) { return(api.CreateFolder("dropbox", "/" + name.Replace('\\', '/'))); }
public Account getInfoAccount(DropboxApi api) { return(api.GetAccountInfo()); }
public static void Download() { if (strDropBoxConnected == "Yes") { try { //var accessToken = GetAccessToken(); var api = new DropboxApi(ConsumerKey, ConsumerSecret, accessToken); var file = api.DownloadFile("dropbox", "StickyNote.xml"); file.Save(Application.StartupPath + "/Data/StickyNote.xml"); } catch (Exception ex) { MessageBox.Show("Download StickyNote failed!"); } } else { DialogResult dr = MessageBox.Show("Do you want to reconnect to Dropbox?", "Confirm!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { Connect(); } } }
public async Task <FileSystemInfo> downloadFileAsync(DropboxApi api, string name) { FileSystemInfo file = await api.DownloadFileAsync("dropbox", name); return(file); }
public async Task <FileSystemInfo> createFolderAsync(DropboxApi api, string name) { FileSystemInfo folder = await api.CreateFolderAsync("dropbox", "/" + name.Replace('\\', '/')); return(folder); }
public async Task <FileSystemInfo> deleteAsync(DropboxApi api, string name) { FileSystemInfo file = await api.DeleteAsync("dropbox", "/" + name.Replace('\\', '/')); return(file); }
public static void Upload() { if (strDropBoxConnected == "Yes") { try { //var accessToken = GetAccessToken(); var api = new DropboxApi(ConsumerKey, ConsumerSecret, accessToken); var file = api.UploadFile("dropbox", "StickyNote.xml", Application.StartupPath + "/Data/StickyNote.xml"); } catch (Exception ex) { MessageBox.Show("Upload StickyNote failed!"); } } }
public DropboxApi connectDropbox(string accesToken) { var api = new DropboxApi(ConsumerKey, ConsumerSecret, accesToken); return(api); }