Click here to Skip to main content
12,945,927 members (53,052 online)
Rate this:
Please Sign up or sign in to vote.
I am currently working on a project in Visual Studio 2012 that needs to send an existing file from one folder to my Dropbox public folder in zipped format, get the Dropbox public link and email the link to a list of users. I am having a problem getting the Dropbox Public Link

I have written a C Sharp Console Application which does the following

1) issue the OpenFileDialog and select the fullpathname

2) build a windows command string to zip the fullpathname and place it in my Dropbox public folder

3) retrieve the Dropbox "Copy Public Link" this is an option in the Dropbpx Context menu

4) build and email and include the Dropbox Public Link in the text. The email is sent with SMTP

I am able to accomplish items 1, 2 and 4 but am unable to do number 3. I do not know how or what callable tool I can use to get the "Public Link" from the DropBox Context menu or if there are any .net commands which I can use to get the information.

all suggestions are welcome. I am new to windows programming as I have been working as a mainframe developer for over 30 years.

Posted 22-Dec-12 2:49am
BillWoodruff 22-Dec-12 10:56am
Is your application, that you want to access the public link for a file in a DropBox 'Public folder: an application that runs on your machine only, and accesses your DropBox folder only ? In other words, do you require remote access to DropBox from another computer which does not have the original DropBox files on it ?

If you are writing an app for your own machine only, to access your own DropBox folder system, only: I may have a work-around for you that will eliminate the complexity involved with using the DropNet library, as described by Zoltán Zörgő, in his solution, below.
rlilley 22-Dec-12 13:46pm
Thanks for the question. This application is running on my PC and will only access my DropBox (Public Folder). I may have found a solution, correct me is I am wrong. In testing my app I was using the DropBox....Copy Public Option menu option and have noticed that all the Public Link URLs are the same except for the last qualifier (the file name). So I was thinking I could hard code the and then concatenate the file name building the proper string.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

As I see, you tried to wrap an application around some existing command line tools and IE. I suggest you look for and use dedicated .net libraries for those tasks.
Like these ones:
1) ZIP:[^]
2) DropBox:[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I can see, by your response to my comment on your question, that you have already figured out the essential aspect of accessing files in your own DropBox, on your own computer.

Yes, DropBox files in the Public folder, on your machine, use a hard-coded six-digit ID number; however, shared files (in a shared folder) will have a dynamically assigned ID number.

Here's some working code pulled from a small Windows Forms test-project I did: note, that, in this project, this is hard-coded for the DropBox folder being on the DeskTop.

Since DropBox does not provide any "public link" to a folder inside the Public folder, the display by this program of folder names preceded by the kind of id you'd want to see on a Public link to a file: is kind of mis-leading: but, I wanted to see the folders separately, as I was developing this little test-bed, for verification purposes, and that's why a 'parse folders only' option is there.
// Windows Forms project, single form
// compiled against FrameWork 3.5
// interface elements on Form1:
    // a large TextBox set MultiLine = true
    // to display the results of parsing the DropBox folder
    // tbDropBoxPublicParseResults
    // a second smaller TextBox set MultiLine = false
    // to display the "stub" for a valid DropBox link
    // tbDropBoxPublicFolderPath
    // a button, and a Click EventHandler
    // to trigger parsing
    // btnParseDropBoxPublicFolder_Click
    // three radiobuttons that determine what to parse
    // rbParseRecursive
    // rbParseTopLevelFiles
    // rbParseTopLevelDirectories
using System;
using System.Text;
// you could omit the 'using statement
// for System.Drawing here, but you must
// have a reference to it for this project
// to compile/run: so I think better to
// leave it in !
using System.Drawing;
using System.Windows.Forms;
using System.IO;
namespace Get_DropBox_Public_Links
    public partial class Form1 : Form
        public Form1()
        // here, I've put "123456," for a six-digit
        // DropBox unique ID: of course that's only
        // a placeholder for your own unique ID ...
        private string DBoxPublicLinkHeader = @"";
        private string replaceSpaceStr = @"%20";
        private string oneSpace = @" ";
        private string newLine = Environment.NewLine;
        private string DTopFolderPath;
        private string DBoxFolderPath;
        private string[] DBoxFolderFiles;
        private string[] DBoxFolderDirectories;
        private string rawLinkPath;
        private string[] whatToParse;
        private int startOfRawLink;
        private void Form1_Load(object sender, EventArgs e)
            // Note the assumption here: the DropBox folder is on the DeskTop
            DTopFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            DBoxFolderPath = DTopFolderPath + @"\DropBox\Public";
            DBoxFolderFiles = Directory.GetFiles(DBoxFolderPath);
            DBoxFolderDirectories = Directory.GetDirectories(DBoxFolderPath);
            startOfRawLink = DBoxFolderPath.Length + 1;
        private void btnParseDropBoxPublicFolder_Click(object sender, EventArgs e)
            tbDropBoxPublicFolderPath.Text = DBoxPublicLinkHeader;
            // handle parsing top-level files:
            // then recurse on all directories
            // and display all files, per directory
            if (rbParseRecursive.Checked)
                RecursiveParse(DBoxFolderFiles, DBoxFolderDirectories);
            // parse either top-level files only, or top-level directories only
            whatToParse = rbParseTopLevelFiles.Checked ? DBoxFolderFiles : DBoxFolderDirectories;
            foreach (string theFilePath in whatToParse)
                rawLinkPath = DBoxPublicLinkHeader + theFilePath.Substring(startOfRawLink);
                rawLinkPath = rawLinkPath.Replace(oneSpace, replaceSpaceStr);
                tbDropBoxPublicParseResults.Text += rawLinkPath + newLine;
        private void RecursiveParse(string[] theFiles, string[] theDirectories)
            foreach (string theFilePath in theFiles)
                rawLinkPath = DBoxPublicLinkHeader + theFilePath.Substring(startOfRawLink);
                rawLinkPath = rawLinkPath.Replace(oneSpace, replaceSpaceStr);
                tbDropBoxPublicParseResults.Text += rawLinkPath + newLine;
            foreach (string theDirectoryPath in theDirectories)
                tbDropBoxPublicParseResults.Text += newLine 
                + "Directory: " 
                + theDirectoryPath 
                + " Total Files = " 
                + theFiles.Length.ToString()
                + newLine;


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 4,899
CHill60 3,205
Maciej Los 2,453
Jochen Arndt 1,935
ppolymorphe 1,795

Advertise | Privacy | Mobile
Web02 | 2.8.170518.1 | Last Updated 23 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100