The first step is to activate the drive API
First, apply for Dropbox's account number, and second, get the app key and app Sercet you need to develop on Dropbox for developers.
1. Login to Dropbox for Developers website, 2, click the App console option, select Create APP;3, click Send Email for verification;4, verify by email, 5, in Create a new On the Dropbox Platform app, choose the Dropbox API app;6, fill in the information and create the app, and you'll get app key and app secret.
Step two, install the Dropbox Client Library
Install a NuGet package (dropnet). If VS2012 selects tools, then NuGet Package Manager, then Package Manager Console. Fill in the Pm> install-package dropnet-pre.
The third step, programming
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Windows.Forms;9 usingdropnet;Ten One namespaceDropnetdemo A { - Public Partial classForm1:form - { the #regionVar - Privatedropnetclient _dropnetclient; - #endregion - + #regionPrivate Property - Privatedropnetclient m_dropnetclient + { A Get at { - return_dropnetclient?? (_dropnetclient =Newdropnetclient (Tbxappkey.text, Tbxappsecret.text)); - } - Set - { -_dropnetclient =value; in } - } to #endregion + - PublicForm1 () the { * InitializeComponent (); $ }Panax Notoginseng - Private voidBtnlogin_click (Objectsender, EventArgs e) the { + varCallbackurl ="https://www.dropbox.com/1/oauth/authorize"; A varCancelcallbackurl ="Https://www.dropbox.com/home"; the varSize =NewSize (1024x768, -); + - if(Dooauth (Callbackurl, cancelcallbackurl, size) = =DialogResult.OK) $ { $ varAccesstoken =M_dropnetclient.getaccesstoken (); - } - } the - PrivateDialogResult Dooauth (stringCallbackurl,stringCancelcallbackurl, System.Drawing.Size Size)Wuyi { the using(varDialog =NewForm ()) - { Wu varBROWESR =NewWebBrowser () - { AboutDock =DockStyle.Fill $ }; - - M_dropnetclient.gettoken (); - varAuthUrl =M_dropnetclient.buildauthorizeurl (); ABROWESR. navigated + = (s, ex) = = + { the varURL =Ex. Url.tostring (); - if(URL.) Equals (Callbackurl)) $ { theDialog. DialogResult =DialogResult.OK; the } the Else if(URL.) Equals (Cancelcallbackurl)) the { -Dialog. DialogResult =DialogResult.Cancel; in } the }; the BROWESR. Navigate (AuthUrl); About theDialog. Size =size; the dialog. Controls.Add (BROWESR); the + returndialog. ShowDialog (); - } the }Bayi the Private voidTbxappkey_textchanged (Objectsender, EventArgs e) the { -M_dropnetclient =NULL; - } the the Private voidTbxappsecret_textchanged (Objectsender, EventArgs e) the { theM_dropnetclient =NULL; - } the } the}
Finally, F5 runs
From: http://www.dotblogs.com.tw/larrynung/archive/2012/07/24/73580.aspx
Http://www.dotblogs.com.tw/larry/nung/archive/2012/08/08/73912.aspx