private void loginForm_Load(object sender, EventArgs e) { this.parent = (MainForm)this.MdiParent; this.parent.StatusLabel = this.LABEL; this.URI_TOKEN = new Uri(this.parent.BaseLink + "Token"); //Dropbox downloader try { string imageLocation = "avatar.png"; DropboxHelper dh = new DropboxHelper(); BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += delegate { dh.Run().Wait(); dh.Download(imageLocation).Wait(); using (var fs = new System.IO.FileStream(imageLocation, System.IO.FileMode.Open)) { var bmp = new Bitmap(fs); this.pictureBox.Image = (Bitmap)bmp.Clone(); } MessageBox.Show("Downloaded pic from dropbox.", "Success"); }; bgw.RunWorkerAsync(); } catch { //silent excception } }
static void Main() { DropboxHelper dh = new DropboxHelper(); // check if it is Up & Running // Lists all files in profiles folder dh.Run().Wait(); // download file with specific name from profiles folder // saves it in bin/debug dh.Download("pesho.bmp").Wait(); try { dh.Download("jm.bmp").Wait(); } catch (Exception ex) { Console.WriteLine(ex.Message); } // upload file with specific name from // bin/debug dh.UploadProfilePicture("gosho.bmp").Wait(); }
private void button1_Click(object sender, EventArgs e) { this.openFileDialog.Title = "Select an avatar."; this.openFileDialog.FileName = ""; this.openFileDialog.Filter = "PNG Images|*.png|JPEG Images|*.jpg|GIF Images|*.gif|BITMAPS|*.bmp"; bool toUpload = false; string imageLocation = string.Empty; if (this.openFileDialog.ShowDialog() == DialogResult.OK) { imageLocation = this.openFileDialog.FileName; using (var fs = new System.IO.FileStream(imageLocation, System.IO.FileMode.Open)) { var bmp = new Bitmap(fs); this.pictureBox.Image = (Bitmap)bmp.Clone(); toUpload = true; } } this.openFileDialog.Dispose(); if (toUpload) { DropboxHelper dh = new DropboxHelper(); BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += delegate { dh.Run().Wait(); dh.UploadProfilePicture(imageLocation).Wait(); MessageBox.Show("Uploaded pic to dropbox.", "Success"); }; bgw.RunWorkerAsync(); } }