DropBox API V2 Integration

Dropbox.NET

  • Dropbox API is a .NET SDK for API v2, which helps you easily integrate Dropbox into your app. The Dropbox .NET SDK is a Portable Class Library that works with multiple platforms, including Windows, Windows Phone, and Mono.

Step 1 Create WPF Application

  • Create new WPF application.

    WPF

Step 2 Install Dropbox.NET SDK in to the project

  • Dropbox.NET SDK can be installed through NuGet.
  • Open NuGet Package Manager Console (PMC) in Visual Studio.

    WPF

  • Run the below mentioned command in PMC to install Dropbox API.

    PM> Install-Package Dropbox.Api
  • Follow the basic steps to complete the installation.
  • After successful installation, Dropbox.Api will be added into the project references.

    WPF

Step 3 Create App in Dropbox

  • Go to the below mentioned link to create account in Dropbox.
    https://www.dropbox.com
  • Navigate to below mentioned link to create new app required to work with Dropbox API.
    https://www.dropbox.com/developers/apps
  • Follow the steps and create new app as per your convenient.

Step 4 Configure Created App for Access

  • Click on created application and redirect to Settings tab.

    WPF

  • Initially only one user can access API and to enable multiple users, click on “Enable additional users” button. This will allow 500 users to use this app for API use.
  • App Key: This is a unique key generated for this app which will be required for the API connection.
  • Redirected URIs: Here, we can add redirection URIs required for the API connection. (For testing purpose, we should add https://localhost.authorize)
  • There is no fix pattern for the URL, We can go with the structure as per our convenient.

Step 5 Start Development for API Integration.

  • In the above 4 steps, we have completed prerequisite steps required to start development related to API Integration.
  • Same as Prerequisite, we have to do some authentication steps to login into Dropbox for Upload, Download etc. operations.

DropBoxBase Class

  • This class contains all the operations related to Dropbox.
    1. using Dropbox.Api;  
    2. using Dropbox.Api.Files;  
    3. using System;  
    4. using System.Collections.Generic;  
    5. using System.IO;  
    6. using System.Linq;  
    7. using System.Net.Http;  
    8. using System.Text;  
    9. using System.Threading.Tasks;  
    10. using System.Windows;  
    11.   
    12. namespace DropBoxIntegration  
    13. {  
    14.     class DropBoxBase  
    15.     {  
    16.         #region Variables  
    17.         private DropboxClient DBClient;  
    18.         private ListFolderArg DBFolders;  
    19.         private string oauth2State;  
    20.         private const string RedirectUri = "https://localhost/authorize"; // Same as we have configured Under [Application] -> settings -> redirect URIs.  
    21.         #endregion  
    22.  
    23.         #region Constructor  
    24.         public DropBoxBase(string ApiKey, string ApiSecret, string ApplicationName = "TestApp")  
    25.         {  
    26.             try  
    27.             {  
    28.                 AppKey = ApiKey;  
    29.                 AppSecret = ApiSecret;  
    30.                 AppName = ApplicationName;  
    31.             }  
    32.             catch (Exception)  
    33.             {  
    34.   
    35.                 throw;  
    36.             }  
    37.         }  
    38.         #endregion  
    39.         #region Properties  
    40.         public string AppName  
    41.         {  
    42.             get; private set;  
    43.         }  
    44.         public string AuthenticationURL  
    45.         {  
    46.             get; private set;  
    47.         }  
    48.         public string AppKey  
    49.         {  
    50.             get; private set;  
    51.         }  
    52.   
    53.         public string AppSecret  
    54.         {  
    55.             get; private set;  
    56.         }  
    57.   
    58.         public string AccessTocken  
    59.         {  
    60.             get; private set;  
    61.         }  
    62.         public string Uid  
    63.         {  
    64.             get; private set;  
    65.         }  
    66.         #endregion  
    67.  
    68.         #region UserDefined Methods  
    69.   
    70.         /// <summary>  
    71.         /// This method is to generate Authentication URL to redirect user for login process in Dropbox.  
    72.         /// </summary>  
    73.         /// <returns></returns>  
    74.         public string GeneratedAuthenticationURL()  
    75.         {  
    76.             try  
    77.             {  
    78.                 this.oauth2State = Guid.NewGuid().ToString("N");  
    79.                 Uri authorizeUri = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Token, AppKey, RedirectUri, state: oauth2State);  
    80.                 AuthenticationURL = authorizeUri.AbsoluteUri.ToString();  
    81.                 return authorizeUri.AbsoluteUri.ToString();  
    82.             }  
    83.             catch (Exception)  
    84.             {  
    85.                 throw;  
    86.             }  
    87.         }  
    88.   
    89.         /// <summary>  
    90.         /// This method is to generate Access Token required to access dropbox outside of the environment (in ANy application).  
    91.         /// </summary>  
    92.         /// <returns></returns>  
    93.         public string GenerateAccessToken()  
    94.         {  
    95.             try  
    96.             {  
    97.                 string _strAccessToken = string.Empty;  
    98.   
    99.                 if (CanAuthenticate())  
    100.                 {  
    101.                     if (string.IsNullOrEmpty(AuthenticationURL))  
    102.                     {  
    103.                         throw new Exception("AuthenticationURL is not generated !");  
    104.   
    105.                     }  
    106.                     Login login = new Login(AppKey, AuthenticationURL, this.oauth2State); // WPF window with Webbrowser control to redirect user for Dropbox login process.  
    107.                     login.Owner = Application.Current.MainWindow;  
    108.                     login.ShowDialog();  
    109.                     if (login.Result)  
    110.                     {  
    111.                         _strAccessToken = login.AccessToken;  
    112.                         AccessTocken = login.AccessToken;  
    113.                         Uid = login.Uid;  
    114.                         DropboxClientConfig CC = new DropboxClientConfig(AppName, 1);  
    115.                         HttpClient HTC = new HttpClient();  
    116.                         HTC.Timeout = TimeSpan.FromMinutes(10); // set timeout for each ghttp request to Dropbox API.  
    117.                         CC.HttpClient = HTC;  
    118.                         DBClient = new DropboxClient(AccessTocken, CC);  
    119.                     }  
    120.                     else  
    121.                     {  
    122.                         DBClient = null;  
    123.                         AccessTocken = string.Empty;  
    124.                         Uid = string.Empty;  
    125.                     }  
    126.                 }  
    127.   
    128.                 return _strAccessToken;  
    129.             }  
    130.             catch (Exception ex)  
    131.             {  
    132.                 throw ex;  
    133.             }  
    134.         }  
    135.   
    136.         /// <summary>  
    137.         /// Method to create new folder on Dropbox  
    138.         /// </summary>  
    139.         /// <param name="path"> path of the folder we want to create on Dropbox</param>  
    140.         /// <returns></returns>  
    141.         public bool CreateFolder(string path)  
    142.         {  
    143.             try  
    144.             {  
    145.                 if (AccessTocken == null)  
    146.                 {  
    147.                     throw new Exception("AccessToken not generated !");  
    148.                 }  
    149.                 if (AuthenticationURL == null)  
    150.                 {  
    151.                     throw new Exception("AuthenticationURI not generated !");  
    152.                 }  
    153.   
    154.                 var folderArg = new CreateFolderArg(path);  
    155.                 var folder = DBClient.Files.CreateFolderAsync(folderArg);  
    156.                 var result = folder.Result;  
    157.                 return true;  
    158.             }  
    159.             catch (Exception ex)  
    160.             {  
    161.                 return false;  
    162.             }  
    163.   
    164.         }  
    165.   
    166.         /// <summary>  
    167.         /// Method is to check that whether folder exists on Dropbox or not.  
    168.         /// </summary>  
    169.         /// <param name="path"> Path of the folder we want to check for existance.</param>  
    170.         /// <returns></returns>  
    171.         public bool FolderExists(string path)  
    172.         {  
    173.             try  
    174.             {  
    175.                 if (AccessTocken == null)  
    176.                 {  
    177.                     throw new Exception("AccessToken not generated !");  
    178.                 }  
    179.                 if (AuthenticationURL == null)  
    180.                 {  
    181.                     throw new Exception("AuthenticationURI not generated !");  
    182.                 }  
    183.   
    184.                 var folders = DBClient.Files.ListFolderAsync(path);  
    185.                 var result = folders.Result;  
    186.                 return true;  
    187.             }  
    188.             catch (Exception ex)  
    189.             {  
    190.                 return false;  
    191.             }  
    192.         }  
    193.   
    194.         /// <summary>  
    195.         /// Method to delete file/folder from Dropbox  
    196.         /// </summary>  
    197.         /// <param name="path">path of file.folder to delete</param>  
    198.         /// <returns></returns>  
    199.         public bool Delete(string path)  
    200.         {  
    201.             try  
    202.             {  
    203.                 if (AccessTocken == null)  
    204.                 {  
    205.                     throw new Exception("AccessToken not generated !");  
    206.                 }  
    207.                 if (AuthenticationURL == null)  
    208.                 {  
    209.                     throw new Exception("AuthenticationURI not generated !");  
    210.                 }  
    211.   
    212.                 var folders = DBClient.Files.DeleteAsync(path);  
    213.                 var result = folders.Result;  
    214.                 return true;  
    215.             }  
    216.             catch (Exception ex)  
    217.             {  
    218.                 return false;  
    219.             }  
    220.         }  
    221.         /// <summary>  
    222.         /// Method to upload files on Dropbox  
    223.         /// </summary>  
    224.         /// <param name="UploadfolderPath"> Dropbox path where we want to upload files</param>  
    225.         /// <param name="UploadfileName"> File name to be created in Dropbox</param>  
    226.         /// <param name="SourceFilePath"> Local file path which we want to upload</param>  
    227.         /// <returns></returns>  
    228.         public bool Upload(string UploadfolderPath, string UploadfileName, string SourceFilePath)  
    229.         {  
    230.             try  
    231.             {  
    232.                 using (var stream = new MemoryStream(File.ReadAllBytes(SourceFilePath)))  
    233.                 {  
    234.                     var response = DBClient.Files.UploadAsync(UploadfolderPath + "/" + UploadfileName, WriteMode.Overwrite.Instance, body: stream);  
    235.                     var rest = response.Result; //Added to wait for the result from Async method  
    236.                 }  
    237.   
    238.                 return true;  
    239.             }  
    240.             catch (Exception ex)  
    241.             {  
    242.                 return false;  
    243.             }  
    244.   
    245.         }  
    246.   
    247.         /// <summary>  
    248.         /// Method to Download files from Dropbox  
    249.         /// </summary>  
    250.         /// <param name="DropboxFolderPath">Dropbox folder path which we want to download</param>  
    251.         /// <param name="DropboxFileName"> Dropbox File name availalbe in DropboxFolderPath to download</param>  
    252.         /// <param name="DownloadFolderPath"> Local folder path where we want to download file</param>  
    253.         /// <param name="DownloadFileName">File name to download Dropbox files in local drive</param>  
    254.         /// <returns></returns>  
    255.         public bool Download(string DropboxFolderPath, string DropboxFileName, string DownloadFolderPath, string DownloadFileName)  
    256.         {  
    257.             try  
    258.             {  
    259.                 var response = DBClient.Files.DownloadAsync(DropboxFolderPath + "/" + DropboxFileName);  
    260.                 var result = response.Result.GetContentAsStreamAsync(); //Added to wait for the result from Async method  
    261.   
    262.                 return true;  
    263.             }  
    264.             catch (Exception ex)  
    265.             {  
    266.                 return false;  
    267.             }  
    268.   
    269.         }  
    270.         #endregion  
    271.         #region Validation Methods  
    272.         /// <summary>  
    273.         /// Validation method to verify that AppKey and AppSecret is not blank.  
    274.         /// Mendatory to complete Authentication process successfully.  
    275.         /// </summary>  
    276.         /// <returns></returns>  
    277.         public bool CanAuthenticate()  
    278.         {  
    279.             try  
    280.             {  
    281.                 if (AppKey == null)  
    282.                 {  
    283.                     throw new ArgumentNullException("AppKey");  
    284.                 }  
    285.                 if (AppSecret == null)  
    286.                 {  
    287.                     throw new ArgumentNullException("AppSecret");  
    288.                 }  
    289.                 return true;  
    290.             }  
    291.             catch (Exception)  
    292.             {  
    293.                 throw;  
    294.             }  
    295.   
    296.         }  
    297.         #endregion  
    298.     }  
    299. }  

Login Window

  • Form to redirect user for login into Dropbox for authentication.

XAML 

  1. <Window x:Class="DropBoxIntegration.Login"  
  2.         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
  3.         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
  4.         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
  5.         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
  6.         xmlns:local="clr-namespace:DropBoxIntegration"  
  7.         mc:Ignorable="d" WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow"  
  8.         Title="Login" BorderThickness="2" BorderBrush="#FF333738" Loaded="Window_Loaded">  
  9.     <Grid>  
  10.         <Grid.ColumnDefinitions>  
  11.             <ColumnDefinition Width="457*"/>  
  12.             <ColumnDefinition Width="30"/>  
  13.         </Grid.ColumnDefinitions>  
  14.         <Grid.RowDefinitions>  
  15.             <RowDefinition Height="30"/>  
  16.             <RowDefinition Height="131*"/>  
  17.         </Grid.RowDefinitions>  
  18.         <Border HorizontalAlignment="Stretch"   
  19.                     VerticalAlignment="Stretch" Margin="2" Grid.Row="1" Grid.ColumnSpan="2" SnapsToDevicePixels="True">  
  20.             <WebBrowser x:Name="Browser" Navigating="Browser_Navigating"/>  
  21.         </Border>  
  22.   
  23.     </Grid>  
  24. </Window>   

.CS Class 

  1. using Dropbox.Api;  
  2. using System;  
  3. using System.Collections.Generic;  
  4. using System.Linq;  
  5. using System.Text;  
  6. using System.Threading.Tasks;  
  7. using System.Windows;  
  8. using System.Windows.Controls;  
  9. using System.Windows.Data;  
  10. using System.Windows.Documents;  
  11. using System.Windows.Input;  
  12. using System.Windows.Media;  
  13. using System.Windows.Media.Imaging;  
  14. using System.Windows.Shapes;  
  15.   
  16. namespace DropBoxIntegration  
  17. {  
  18.     /// <summary>  
  19.     /// Interaction logic for Login.xaml  
  20.     /// </summary>  
  21.     public partial class Login : Window  
  22.     {  
  23.         #region Variables  
  24.         private const string RedirectUri = "https://localhost/authorize";  
  25.         private string DBAppKey = string.Empty;  
  26.         private string DBAuthenticationURL = string.Empty;  
  27.         private string DBoauth2State = string.Empty;  
  28.         #endregion  
  29.  
  30.         #region Properties  
  31.         public string AccessToken { get; private set; }  
  32.   
  33.         public string UserId { get; private set; }  
  34.   
  35.         public bool Result { get; private set; }  
  36.         #endregion  
  37.   
  38.   
  39.         public Login(string AppKey, string AuthenticationURL, string oauth2State)  
  40.         {  
  41.             InitializeComponent();  
  42.             DBAppKey = AppKey;  
  43.             DBAuthenticationURL = AuthenticationURL;  
  44.             DBoauth2State = oauth2State;  
  45.         }  
  46.   
  47.         public void Navigate()  
  48.         {  
  49.             try  
  50.             {  
  51.                 if (!string.IsNullOrEmpty(DBAppKey))  
  52.                 {  
  53.                     Uri authorizeUri = new Uri(DBAuthenticationURL);  
  54.                     Browser.Navigate(authorizeUri);  
  55.                 }  
  56.             }  
  57.             catch (Exception)  
  58.             {  
  59.                 throw;  
  60.             }  
  61.         }  
  62.   
  63.         private void Window_Loaded(object sender, RoutedEventArgs e)  
  64.         {  
  65.             Dispatcher.BeginInvoke(new Action(Navigate));  
  66.             // Navigate();  
  67.         }  
  68.   
  69.         private void Button_Click(object sender, RoutedEventArgs e)  
  70.         {  
  71.             try  
  72.             {  
  73.                 this.Close();  
  74.             }  
  75.             catch (Exception)  
  76.             {  
  77.                 throw;  
  78.             }  
  79.   
  80.         }  
  81.   
  82.         private void Browser_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e)  
  83.         {  
  84.             if (!e.Uri.AbsoluteUri.ToString().StartsWith(RedirectUri.ToString(), StringComparison.OrdinalIgnoreCase))  
  85.             {  
  86.                 // we need to ignore all navigation that isn't to the redirect uri.  
  87.                 return;  
  88.             }  
  89.   
  90.   
  91.             try  
  92.             {  
  93.   
  94.                 OAuth2Response result = DropboxOAuth2Helper.ParseTokenFragment(e.Uri);  
  95.                 if (result.State != DBoauth2State)  
  96.                 {  
  97.                     return;  
  98.                 }  
  99.   
  100.                 this.AccessToken = result.AccessToken;  
  101.                 this.Uid = result.Uid;  
  102.                 this.Result = true;  
  103.             }  
  104.   
  105.             catch (ArgumentException ex)  
  106.             {  
  107.             }  
  108.   
  109.             finally  
  110.             {  
  111.                 e.Cancel = true;  
  112.                 this.Close();  
  113.             }  
  114.         }  
  115.     }  
  116. }   

MainWindow

  • UI Interface to work with Dropbox.

Xaml 

  1. <Window x:Class="DropBoxIntegration.MainWindow"  
  2.         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
  3.         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
  4.         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
  5.         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
  6.         xmlns:local="clr-namespace:DropBoxIntegration"  
  7.         mc:Ignorable="d"  
  8.         Title="MainWindow" Height="321" Width="1024" MinHeight="300" MinWidth="600">  
  9.     <Grid>  
  10.         <Grid.RowDefinitions>  
  11.             <RowDefinition Height="35"/>  
  12.             <RowDefinition Height="70"/>  
  13.             <RowDefinition Height="113*"/>  
  14.             <RowDefinition Height="20"/>  
  15.         </Grid.RowDefinitions>  
  16.         <Label Content="Work with your DropBox account" FontSize="18" Foreground="Black" FontWeight="SemiBold" Margin="20,0,5,0"></Label>  
  17.         <GroupBox x:Name="gbAuthentication" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Grid.Row="1" Background="White">  
  18.             <GroupBox.Header>  
  19.                 <Label Content="DropBox Authentication" FontWeight="SemiBold"></Label>  
  20.             </GroupBox.Header>  
  21.             <Grid>  
  22.                 <Grid.ColumnDefinitions>  
  23.                     <ColumnDefinition Width="100"/>  
  24.                     <ColumnDefinition Width="100*"/>  
  25.                     <ColumnDefinition Width="100"/>  
  26.                 </Grid.ColumnDefinitions>  
  27.                 <Label Content="App Key: " Grid.Column="0" HorizontalContentAlignment="Right" Margin="2"/>  
  28.                 <TextBox x:Name="txtApiKey" Grid.Column="1" Margin="2" MaxLength="100" Text=""></TextBox>  
  29.                 <Button Content="Authenticate" x:Name="btnApiKey" Grid.Column="2" Margin="2" Click="btnApiKey_Click"></Button>  
  30.             </Grid>  
  31.   
  32.         </GroupBox>  
  33.         <GroupBox x:Name="gbDropBox" HorizontalAlignment="Stretch" Margin="2" Grid.Row="2" VerticalAlignment="Stretch" Background="White" IsEnabled="false">  
  34.             <GroupBox.Header>  
  35.                 <Label Content="DropBox Operations" FontWeight="SemiBold"></Label>  
  36.             </GroupBox.Header>  
  37.             <Grid>  
  38.                 <Grid.ColumnDefinitions>  
  39.                     <ColumnDefinition Width="05"/>  
  40.                     <ColumnDefinition Width="220*"/>  
  41.                     <ColumnDefinition Width="220*"/>  
  42.                     <ColumnDefinition Width="220*"/>  
  43.                     <ColumnDefinition Width="220*"/>  
  44.                     <ColumnDefinition Width="05"/>  
  45.                 </Grid.ColumnDefinitions>  
  46.                 <Grid.RowDefinitions>  
  47.                     <RowDefinition Height="05"/>  
  48.                     <RowDefinition Height="150*"/>  
  49.                     <RowDefinition Height="05"/>  
  50.                 </Grid.RowDefinitions>  
  51.                 <Button x:Name="btnCreateFolder" Content="Create Folder" HorizontalAlignment="Stretch" Margin="5" VerticalAlignment="Stretch" Grid.Row="1" Grid.Column="1" FontSize="14" Click="btnCreateFolder_Click"/>  
  52.                 <Button x:Name="btlUpload" Content="Upload File" HorizontalAlignment="Stretch" Margin="5" VerticalAlignment="Stretch" Grid.Row="1" Grid.Column="2" FontSize="14" Click="btlUpload_Click"/>  
  53.                 <Button x:Name="btnDownload" Content="Download File" HorizontalAlignment="Stretch" Margin="5" VerticalAlignment="Stretch" Grid.Row="1" Grid.Column="3" FontSize="14" Click="btnDownload_Click"/>  
  54.                 <Button x:Name="btnDelete" Content="Delete File/Directory" HorizontalAlignment="Stretch" Margin="5" VerticalAlignment="Stretch" Grid.Row="1" Grid.Column="4" FontSize="14" Click="btnDelete_Click"/>  
  55.             </Grid>  
  56.   
  57.         </GroupBox>  
  58.   
  59.     </Grid>  
  60. </Window>   

.CS File 

  1. using Dropbox.Api;  
  2. using System;  
  3. using System.Collections.Generic;  
  4. using System.Linq;  
  5. using System.Text;  
  6. using System.Threading.Tasks;  
  7. using System.Windows;  
  8. using System.Windows.Controls;  
  9. using System.Windows.Data;  
  10. using System.Windows.Documents;  
  11. using System.Windows.Input;  
  12. using System.Windows.Media;  
  13. using System.Windows.Media.Imaging;  
  14. using System.Windows.Navigation;  
  15. using System.Windows.Shapes;  
  16.   
  17. namespace DropBoxIntegration  
  18. {  
  19.     /// <summary>  
  20.     /// Interaction logic for MainWindow.xaml  
  21.     /// </summary>  
  22.     public partial class MainWindow : Window  
  23.     {  
  24.         #region Variables  
  25.         private string strAppKey = "[Yor Application App Key]";  
  26.         private string strAccessToken = string.Empty;  
  27.         private string strAuthenticationURL = string.Empty;  
  28.         private DropBoxBase DBB;  
  29.         #endregion  
  30.  
  31.         #region Constructor  
  32.         public MainWindow()  
  33.         {  
  34.             InitializeComponent();  
  35.         }  
  36.         #endregion  
  37.  
  38.         #region Private Methods  
  39.         public void Authenticate()  
  40.         {  
  41.             try  
  42.             {  
  43.                 if (string.IsNullOrEmpty(strAppKey))  
  44.                 {  
  45.                     MessageBox.Show("Please enter valid App Key !");  
  46.                     return;  
  47.                 }  
  48.                 if (DBB == null)  
  49.                 {  
  50.                     DBB = new DropBoxBase(strAppKey, "PTM_Centralized");  
  51.   
  52.                     strAuthenticationURL = DBB.GeneratedAuthenticationURL(); // This method must be executed before generating Access Token.  
  53.                     strAccessToken = DBB.GenerateAccessToken();  
  54.                     gbDropBox.IsEnabled = true;  
  55.                 }  
  56.                 else gbDropBox.IsEnabled = false;  
  57.             }  
  58.             catch (Exception)  
  59.             {  
  60.                 throw;  
  61.             }  
  62.         }  
  63.         #endregion  
  64.   
  65.         private void btnApiKey_Click(object sender, RoutedEventArgs e)  
  66.         {  
  67.             try  
  68.             {  
  69.                 strAppKey = txtApiKey.Text.Trim();  
  70.                 Authenticate();  
  71.             }  
  72.             catch (Exception)  
  73.             {  
  74.                 throw;  
  75.             }  
  76.   
  77.         }  
  78.   
  79.         private void btnCreateFolder_Click(object sender, RoutedEventArgs e)  
  80.         {  
  81.             try  
  82.             {  
  83.                 if (DBB != null)  
  84.                 {  
  85.                     if (strAccessToken != null && strAuthenticationURL != null)  
  86.                     {  
  87.                         if (DBB.FolderExists("/Dropbox/DotNetApi") == false)  
  88.                         {  
  89.                             DBB.CreateFolder("/Dropbox/DotNetApi");  
  90.                         }  
  91.                     }  
  92.                 }  
  93.             }  
  94.             catch (Exception ex)  
  95.             {  
  96.                 ex = ex.InnerException ?? ex;  
  97.             }  
  98.         }  
  99.   
  100.         private void btlUpload_Click(object sender, RoutedEventArgs e)  
  101.         {  
  102.             try  
  103.             {  
  104.                 if (DBB != null)  
  105.                 {  
  106.                     if (strAccessToken != null && strAuthenticationURL != null)  
  107.                     {  
  108.                         DBB.Upload("/Dropbox/DotNetApi""Sample-test.jpg", @"D:\Capture4-test.PNG");  
  109.                     }  
  110.                 }  
  111.             }  
  112.             catch (Exception)  
  113.             {  
  114.   
  115.                 throw;  
  116.             }  
  117.         }  
  118.   
  119.         private void btnDownload_Click(object sender, RoutedEventArgs e)  
  120.         {  
  121.             try  
  122.             {  
  123.                 if (DBB != null)  
  124.                 {  
  125.                     if (strAccessToken != null && strAuthenticationURL != null)  
  126.                     {  
  127.                         DBB.Download("/Dropbox/DotNetApi""Sample-test.jpg", @"D:\", "capture4_dwnld.png");  
  128.                     }  
  129.                 }  
  130.             }  
  131.             catch (Exception)  
  132.             {  
  133.   
  134.                 throw;  
  135.             }  
  136.         }  
  137.   
  138.         private void btnDelete_Click(object sender, RoutedEventArgs e)  
  139.         {  
  140.             try  
  141.             {  
  142.                 if (DBB != null)  
  143.                 {  
  144.                     if (strAccessToken != null && strAuthenticationURL != null)  
  145.                     {  
  146.                         DBB.Delete("/Dropbox/DotNetApi");  
  147.                     }  
  148.                 }  
  149.             }  
  150.             catch (Exception)  
  151.             {  
  152.   
  153.                 throw;  
  154.             }  
  155.         }  
  156.   
  157.   
  158.     }  
  159. }   

That’s it. We are done with the integration. Enjoy Coding !

Up Next
    Ebook Download
    View all
    Learn
    View all