SharpBox example for VB.Net

Aug 28, 2011 at 8:48 PM

Is there an example of all code required in VB.Net to download a file from Dropbox please ?

Regards,

John

Coordinator
Aug 28, 2011 at 10:36 PM
Hi,

sorry I have no direct example. Any body in the community, sorry I'm not the VB crack!

Thanks
Dirk


2011/8/28 Spindrift <notifications@codeplex.com>

From: Spindrift

Is there an example of all code required in VB.Net to download a file from Dropbox please ?

Regards,

John

Read the full discussion online.

To add a post to this discussion, reply to this email (sharpbox@discussions.codeplex.com)

To start a new discussion for this project, email sharpbox@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Oct 7, 2011 at 2:37 AM

Quick Example
Dim App As New Note_Master.CloudApp.App("ABC@gmail.com", "o.O")
App.Cloud.DownloadFile(FilePath, TargetPath)












Cool Wrapper for my work


Imports AppLimit.CloudComputing.SharpBox


''' <summary>
''' 
''' </summary>
''' <remarks></remarks>
''' <features></features>
''' <stepthrough></stepthrough>
Public NotInheritable Class CloudApp
    Private Sub New()
    End Sub

    Public Shared Sub UploadNotes(ByVal User As User)
        Throw New ApplicationException("Feature Not Constructed Yet")
        'Note_Master.Data.Seralize.Write_All_Data()


        'User.Cloud.UploadFile(User.Location, )
    End Sub


    ''' <summary>
    ''' Shows A ValueSelector with all Users in the ComboBox to Select From
    ''' </summary>
    ''' <param name="Title">The Optional Title for the ValueSelector(Default = "Select A User")</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    ''' <stepthrough></stepthrough>
    Public Shared Function SelectUser(Optional ByVal Title As String = "Select A User") As String
        Dim App As New Note_Master.CloudApp.App("XXXX@gmail.com", "O.o")
        Return Aaron.Controls.PropertyGrids.ValueSelector.Grab(App.Users.Users.ForEach_Strings(Function(x) x.Key), Title)
    End Function


End Class

Partial Class CloudApp

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    ''' <features></features>
    ''' <stepthrough>Enabled</stepthrough>
    <DebuggerStepThrough()>
    Public Class App
        Public Property Cloud As New CloudStorage

        Dim _Users As AppUsers
        Public ReadOnly Property Users As AppUsers
            Get
                Return _Users
            End Get
        End Property

        Public ReadOnly Property InstallFolder As ICloudDirectoryEntry
            Get
                Return Cloud.CreateFolder("/Install")
            End Get
        End Property

        Public ReadOnly Property PublicFolder As ICloudDirectoryEntry
            Get
                Return Cloud.CreateFolder("/Public")
            End Get
        End Property

        'Public ReadOnly Property Storage As ICloudDirectoryEntry
        '    Get
        '        Return Cloud.CreateFolder("/Storage")
        '    End Get
        'End Property

        Public ReadOnly Property Storage As BaseFolder
            Get
                Return New BaseFolder(Cloud, "/Storage")
            End Get
        End Property


        ''' <summary>
        ''' 
        ''' </summary>
        ''' <param name="Email"></param>
        ''' <param name="Password"></param>
        ''' <param name="ConsumerKey"></param>
        ''' <param name="ConsumerSecret"></param>
        ''' <remarks></remarks>
        ''' <stepthrough>Enabled</stepthrough>
        Sub New(ByVal Email As String, ByVal Password As String, Optional ByVal ConsumerKey As String = "l2pq95nq3wxmlt7", Optional ByVal ConsumerSecret As String = "ajfu0aer1c5bh9c")
            Dim dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox)
            Dim dropBoxCredentials As New StorageProvider.DropBox.DropBoxCredentials With {.UserName = Email, .Password = Password,
                                                                                           .ConsumerKey = ConsumerKey, .ConsumerSecret = ConsumerSecret}
            Dim storageToken = Cloud.Open(dropBoxConfig, dropBoxCredentials)
            _Users = New AppUsers(Cloud)
        End Sub


    End Class



    Public Class AppUsers
        Inherits BaseFolder

        Default Public ReadOnly Property User(ByVal Name As String) As User
            Get
                Return Users(Name)
            End Get
        End Property

        Public ReadOnly Property Users As Dictionary(Of String, User)
            Get
                Dim List As New Dictionary(Of String, User)
                For Each Item As ICloudDirectoryEntry In Folder
                    List.Add(Item.Name, New User(Me.Cloud, Item.Name))
                Next
                Return List
            End Get
        End Property

        Sub New(ByRef Cloud As CloudStorage)
            MyBase.New(Cloud, "/Users")
        End Sub


        Public Sub AddUser(ByVal Name As String)
            Me.AddFolder(Name)
        End Sub

        Public Sub DeleteUser(ByVal Name As String)
            Me.DeleteFolderOrFolder(Name)
        End Sub


    End Class



    Public Class User
        Inherits BaseFolder
        Public Property Name As String


        Public ReadOnly Property Inbox As ICloudDirectoryEntry
            Get
                Return Cloud.CreateFolder("/Users/" & Name & "/Inbox")
            End Get
        End Property


        Public ReadOnly Property System As ICloudDirectoryEntry
            Get
                Return Cloud.CreateFolder("/Users/" & Name & "/System")
            End Get
        End Property



        Sub New(ByRef Cloud As CloudStorage, ByVal Name As String)
            MyBase.New(Cloud, "/Users/" & Name)
        End Sub



    End Class



    Public Class BaseFolder
        Dim _Cloud As CloudStorage
        Public ReadOnly Property Cloud As CloudStorage
            Get
                Return _Cloud
            End Get
        End Property

        Dim _Location As String
        Public ReadOnly Property Location As String
            Get
                Return _Location
            End Get
        End Property


        Public ReadOnly Property Folder As ICloudDirectoryEntry
            Get
                Return Cloud.CreateFolder(_Location)
            End Get
        End Property


        Sub New(ByRef Cloud As CloudStorage, ByVal Location As String)
            Me._Cloud = Cloud
            Me._Location = Location
        End Sub


        Public Function UploadFile(ByVal Location As String) As ICloudFileSystemEntry
            Return Cloud.UploadFile(Location, Me.Folder)
        End Function


        Public Sub DownloadFile(ByVal FileName As String, ByVal Folder As String)
            Cloud.DownloadFile(Me._Location & "/" & FileName, Folder)
        End Sub

        Public Function AddFolder(ByVal Folder As String) As ICloudFileSystemEntry
            Return Cloud.CreateFolder(Me._Location & "/" & Folder)
        End Function


        Public Sub DeleteFolderOrFolder(ByVal Name As String)
            Cloud.DeleteFileSystemEntry(Me._Location & "/" & Name)
        End Sub



    End Class

End Class