cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you using the Microsoft co-authoring beta for Dropbox? Share your feedback and learn more about it here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Download one file in ASP.net VB

Download one file in ASP.net VB

pw200
New member | Level 2
Go to solution

Good day all

 

I'm really sorry if this question has been asked before, I have searched a lot without success. I want to download one file from my own account using ASP.net, but using VB (not C#). I have downloaded the V2 API package 

 

 PM> Install-Package Dropbox.Api

 

I have tried without using the above SDK using this code. Although a file is created on my computer its full of junk.

 

    Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


Dim UrlPath As String = "https://www.dropbox.com/s/quswjzadmomb6xz/Linux.txt?dl=0" ' make sure you get the download path of the file in this format
        Dim DownloadToThisFilename As String = "C:\test\FileName.txt"  ' filename for the file to be downloaded to
        Try
            Using Client As New System.Net.WebClient()
                Client.DownloadFile(UrlPath, DownloadToThisFilename)
            End Using
        Catch

            MsgBox("Issues")


        End Try



    End Sub

Two solutions I think are possible and I would be happy with either

 

1. A VB solution that is similar to the above  

 

or

 

2. A solution that does use the SDK, but once again written in VB

 

Any help very much appreciated

 

Peter

 

PS - its an Excel file I want to download if that makes any difference

 

 

 

 

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
1. If you have a shared link to a file, you can download it directly. Note that the link you shared in your code though points to the HTML preview page for the file, not the file data itself, so your code won't work as is.

You can modify these links to point to the file data though, as documented here:

https://www.dropbox.com/help/desktop-web/force-download

2 Alternatively, you can use the official Dropbox API v2 .NET SDK:

https://github.com/dropbox/dropbox-sdk-dotnet

With that, you can use the GetSharedLinkFile method to download a file from a shared link:

https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Sharing_Routes_SharingUserRoutes_Get...

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution
1. If you have a shared link to a file, you can download it directly. Note that the link you shared in your code though points to the HTML preview page for the file, not the file data itself, so your code won't work as is.

You can modify these links to point to the file data though, as documented here:

https://www.dropbox.com/help/desktop-web/force-download

2 Alternatively, you can use the official Dropbox API v2 .NET SDK:

https://github.com/dropbox/dropbox-sdk-dotnet

With that, you can use the GetSharedLinkFile method to download a file from a shared link:

https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Sharing_Routes_SharingUserRoutes_Get...

pw200
New member | Level 2
Go to solution

Greg

 

A massive thank you for the fast and accurate reply. Just changing the 0 to a 1 at the end of the link ensured I got the file I was expecting. The SDK option is good information as well, and I have saved that link for future reference

 

Again thank you for taking the time to help me out, I really appreciate it

 

regards

 

Peter

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    pw200 New member | Level 2
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?