示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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));
        }
示例#4
0
        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();
        }
示例#6
0
        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();
        }
示例#7
0
        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;
        }
示例#8
0
        public async Task <File> viewFilesAsync(DropboxApi api, string name)
        {
            File file = await api.GetFilesAsync("auto", name);

            return(file);
        }
示例#9
0
 public File viewFiles(DropboxApi api, string name)
 {
     return(api.GetFiles("dropbox", name));
 }
示例#10
0
 public FileSystemInfo downloadFile(DropboxApi api, string name)
 {
     return(api.DownloadFile("dropbox", name));
 }
示例#11
0
        public async Task <Account> getInfoAccountAsync(DropboxApi api)
        {
            Account account = await api.GetAccountInfoAsync();

            return(account);
        }
示例#12
0
 public FileSystemInfo delete(DropboxApi api, string name)
 {
     return(api.Delete("dropbox", "/" + name.Replace('\\', '/')));
 }
示例#13
0
 public FileSystemInfo createFolder(DropboxApi api, string name)
 {
     return(api.CreateFolder("dropbox", "/" + name.Replace('\\', '/')));
 }
示例#14
0
 public Account getInfoAccount(DropboxApi api)
 {
     return(api.GetAccountInfo());
 }
示例#15
0
 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();
         }
     }
 }
示例#16
0
        public async Task <FileSystemInfo> downloadFileAsync(DropboxApi api, string name)
        {
            FileSystemInfo file = await api.DownloadFileAsync("dropbox", name);

            return(file);
        }
示例#17
0
        public async Task <FileSystemInfo> createFolderAsync(DropboxApi api, string name)
        {
            FileSystemInfo folder = await api.CreateFolderAsync("dropbox", "/" + name.Replace('\\', '/'));

            return(folder);
        }
示例#18
0
        public async Task <FileSystemInfo> deleteAsync(DropboxApi api, string name)
        {
            FileSystemInfo file = await api.DeleteAsync("dropbox", "/" + name.Replace('\\', '/'));

            return(file);
        }
示例#19
0
 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!");
         }
     }
 }
示例#20
0
        public DropboxApi connectDropbox(string accesToken)
        {
            var api = new DropboxApi(ConsumerKey, ConsumerSecret, accesToken);

            return(api);
        }