cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Do you want to help improve our online support experience? Learn more
Highlighted
Level 6

Path Not Found Error

I'm trying to download a simple file from a Dropbox for a rather large C# program I am developing. 

My file path for the file in the dropbox is:

"C://Users//xxxx//Dropbox (MAD treat)//C#//Sweetners.docx"

 

I've also tried to get this to work by placing the file just in the dropbox: 

"C://Users//xxxx//Dropbox (MAD treat)//Sweetners.docx"

Here's the coding I am using: 

public async Task<bool> Download() {
DBClient = new DropboxClient("zy4WfD_K0CME67Ng6123123123123123123123vCs5ye3LR4FQ5WbbQc7SETCETCETCNotTheRealAuthentication");

 

try {
var localFilePath = @"C:/C# Production";
string folder = "/C#";
string file = "Sweetners.doc";
using(var response = await DBClient.Files.DownloadAsync(folder + "/" + file)) {
using(var fileStream = File.Create(localFilePath)) {
(await response.GetContentAsStreamAsync()).CopyTo(fileStream);
}
}
return true;

}

 

catch(Exception ex) {
MessageBox.Show(ex.ToString());
return false;
}

}

============================

When I step through this, I get a "path not found" error at "await DBClient.Files.DownloadAsync(folder + "/" + file)" request. 

I have tried various combinations of folder and file, including. . . 

folder = "/Dropbox (MAD treat)/C#" and "/C#", "//Dropbox (MAD treat)//C#" and "//C#"

and file = "Sweetner.docx" and "Sweetner.doc", as well as "/Sweetner.docx" and "/Sweetner.doc"

I've also tried just using "/Dropbox (MAD treat)/C#/Sweetners.docx",  "//Dropbox (MAD treat)//C#//Sweetners.docx", and "//Dropbox 

All to no avail! I keep getting the "file path not found" error. 

Is this because DBClient.Files.DownloadAsync doesn't recognize spaces in the "Dropbox (Mad treat)" folder. . . spaces that I can't remove?? 

Thanks in advance!!


 

1 Accepted best answer

Accepted Solutions
Level 6

Re: Path Not Found Error

Thanks!

I finally figured out that the default directory was "\\Apps\\MyAppFolder". . . . and that was the only folder I could read from or write to without going to the "production" mode. Part of the confusion was I was trying to use some subdirectories to the default directory to. 

Reply
Loading...
4 Replies
Dropboxer

Re: Path Not Found Error

When referencing files via path on the Dropbox API, the path will be relative to the root of the Dropbox, not including any local filesystem components from linked computers.

So, in your case, the right value would be one of these, for whatever the actual file extension is for the uploaded file:
/C#/Sweetners.docx
/C#/Sweetners.doc

The API and .NET SDK can handle special characters, such as spaces and '#'.

In order to get the right path values though, you can list the contents of a folder using ListFolderAsync:

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

You can supply "" as the path to list the contents of the root folder, or any subfolder such as "/C#". You can then get the resulting 'PathLower' value for the desired file and use that in DownloadAsync.
Reply
Loading...
Level 6

Re: Path Not Found Error

I think maybe I've figured out my problem. . . but still don't have a solution for it. 

When my program runs the command 

using(var response = await DBClient.Files.DownloadAsync(folder + "/" + file)) {}

the only way it works is if (folder + "/" + file) is empty -- ie, (String.Empty) works, and should return the "Dropbox Root" directory. However, this returns zero files and zero folders. . . although there are both files and folders. 

I think this is because my App is not "published" yet, and the only folder I can access in this mode is "/Dropbox/Apps", or in my case "/Dropbox (MAD Treat)/Apps". 

I would think that "/Apps" should be sufficient to get me to that folder. . but it doesn't. 

Neither does "//Apps" nor @"/Apps", or for that matter, "\\Apps" nor @"\Apps"

Once again, thanks for your help. . . .


Reply
Loading...
Dropboxer

Re: Path Not Found Error

The DownloadAsync method does not support the empty string as the path value. The empty string would refer to root, a folder, but the DownloadAsync method only supports files.

You may actually be referring to the ListFolderAsync method, which does support the empty string, which is the right way to list the contents of root.

Note that for apps with the app folder permission though, "root" is interpreted as the root of the special app folder made for the app, which is empty when first created. If it is still empty, you will correctly get an empty list back.

This is not related to whether or not your app is "published". You also do not need to include the "/Apps" path component yourself.
Reply
Loading...
Level 6

Re: Path Not Found Error

Thanks!

I finally figured out that the default directory was "\\Apps\\MyAppFolder". . . . and that was the only folder I could read from or write to without going to the "production" mode. Part of the confusion was I was trying to use some subdirectories to the default directory to. 

Reply
Loading...
END WEBSITE FEEDBACK SNIPPET-->