To Download file from DropBox please use next code:

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Action<byte[]> callback = DownloadCompleted;

            DropBoxy.DropBoxyEngine engine = new DropBoxy.DropBoxyEngine();
            engine.ApiKey = "api key";
            engine.ApiSecret = "api secret";

            engine.SetToken("usertoken", "usersecret");
            engine.DownloadFile("newtxt.txt", callback);
            //if you want to download file from for example public folder use /Public/newtxt.txt
          
        }
This peace of code will download file from the root folder called "newtxt.txt".

Last edited Jan 15, 2011 at 1:34 PM by dimko1, version 1

Comments

Sparks260 Sep 4, 2011 at 9:12 PM 
Download works -- see my reply in the Discussions.

timb320 Mar 11, 2011 at 8:11 PM 
Not sure if this may have a bearing bot I read in another site where they were developing a similar lib that thier dowload routine could only download text files and not data files: "Fixed a bug in the code that only allowed for text based files to be downloaded. Using restClient.DownloadData now instead of Execute to get the response’s raw Data."
I Notices in your routine your using restClient.ExecuteAsync , not sure if this is something you should look at..

timb320 Mar 11, 2011 at 3:56 AM 
For the Life of me I cannot get this to work in Wp7, i.e. trying to use the callback function to write the data/bytes to isolated storage just writes a file of the length in bytes but it the byte array contains nothing therefore the file is useless. Here is the code (what am I doing wrong here?):


public void RestoreCompleted(byte [] download)
{

IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
//byte[] data = download;
if (file.FileExists("GeoPositions.dat"))
{
file.DeleteFile("GeoPositions.dat");
}

var fs = new IsolatedStorageFileStream("GeoPositions.dat", System.IO.FileMode.Create, file);
try
{
fs.Write(download, 0, download.Length);
}
catch (Exception err)
{

}
finally
{
if (null != fs)
{
fs.Close();
}
MessageBox.Show("Restore from DropBox Completed!");
}


//DataUpload.Visibility = System.Windows.Visibility.Collapsed;



}

Download func excerpt based on your sample :
Note: I declared the engine at the begining of page class.
private void RestoreFromDropBox_Click(object sender, EventArgs e)
{
if (User_api_key == "" && User_api_secret == "")
{
Login();
}
Action<byte[]> callback = RestoreCompleted;

engine.ApiKey = api_key;
engine.ApiSecret = api_secret;
engine.SetToken(User_api_key, User_api_secret);
try
{
engine.DownloadFile("GeoPositions.dat", callback);

}