Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
            }
        }
        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();
            }
        }