You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
ccap
7 years agoExplorer | Level 4
Download error - path not found (.NET)
My dropbox business account has the following:
Folder A - My Personal User Folder
Folder B - Dropbox business team folder (Let's call this "TestTeam")
And .txt files named test.txt, one in each folder (Folder A, Folder B, and the root "TestTeam")
My Dropbox app is a Dropbox API app with Full Dropbox permission.
Using DownloadAsync, I am only able to download from the root with path "/test.txt"
Trying to download a file from paths "/Folder A/test.txt" (personal folder) or "/Folder B/test.txt" (team folder) gives me a path not found error.
Below is the code of my Download function.
private async Task Download(DropboxClient client, string path, string fileName) { using (var response = await client.Files.DownloadAsync(path)) { var strm = await response.GetContentAsStreamAsync(); string localFilePath = @"C:\Users\MyPC\Desktop\" + fileName; using (var fileStream = File.Create(localFilePath)) { strm.CopyTo(fileStream); } } }
You should be passing in the PathLower value in particular when calling DownloadAsync. (For printing, PathDisplay or Name would be appropriate.)
I don't see where you're connecting this to your Download method, but make sure you're using PathLower for the actual download call. Name is only the last path component, not the full path.
If you pass in PathLower, that should work, as long as you have a client with the correct "PathRoot".
- Greg-DBDropbox Staff
A 'path/not_found' error indicates that nothing was found at the path supplied. In this case, that's the 'path' variable in your code. It sounds like you're not providing the correct path value for the files you're attempting to access.
I can't say exactly what the correct path is in your case, without knowing the state of your Dropbox. It sounds like you're using the "team space" configuration, and API calls default to your member folder, so for example, to access a file in a folder in your member folder, the path would look like "/SomeFolderName/file.ext".
You can use ListFolderAsync and ListFolderContinueAsync to list the contents of a folder to get the paths programmatically.
I recommend reviewing the Namespace Guide and the Content Access Guide for information on how to reference and access different pieces of content. (For reference, using the .NET SDK, you can set the Dropbox-API-Path-Root Header mentioned there using DropboxClient.WithPathRoot.)
- ccapExplorer | Level 4
Using ListFolderAsync, I can successfully iterate through my full directory and get the path for all folders and files in my root, personal user folders, as well as team folders. I can't download from the paths that I get from this list, such as "/Folder A/test.txt". I can only download from my root directory for some reason. Below is the list code I'm using to create new divs for each folder/file. Clicking a folder div takes you into the next path. Clicking a file is supposed to download that file using the current path+file name, but thats where I'm getting path not found unless I try to download the root directory file only.
private async Task<ListFolderResult> ListFolder(DropboxClient client, string path) { Debug.Print("--- Files ---"); var list = await client.Files.ListFolderAsync(path); // Show folders then files foreach (var item in list.Entries.Where(i => i.IsFolder)) { Debug.Print("D {0}/", item.Name); newFolderDiv(item.Name, item.PathDisplay); } foreach (var item in list.Entries.Where(i => i.IsFile)) { var file = item.AsFile; Debug.Print("F {0}/", item.Name); Debug.Print("Path is: " + item.PathDisplay); newFileDiv(item.Name, item.PathLower); } if (list.HasMore) { Debug.Print(" ..."); } return list; } private async Task<ListFolderResult> ListFolderInTeamSpace(DropboxClient client, string path) { // Fetch root namespace info from user's account info. var account = await client.Users.GetCurrentAccountAsync(); if (!account.RootInfo.IsTeam) { Debug.Print("This user doesn't belong to a team with shared space."); return null; } else { // Point path root to namespace id of team space. client = client.WithPathRoot(new PathRoot.Root(account.RootInfo.RootNamespaceId)); var list = await ListFolder(client, path); return list; } }
Is it possible that the path that ListFolder gets for the file isn't the same path that I can use to print? But then why does it work for the root directory... ("/test.txt")
- Greg-DBDropbox Staff
You should be passing in the PathLower value in particular when calling DownloadAsync. (For printing, PathDisplay or Name would be appropriate.)
I don't see where you're connecting this to your Download method, but make sure you're using PathLower for the actual download call. Name is only the last path component, not the full path.
If you pass in PathLower, that should work, as long as you have a client with the correct "PathRoot".
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,915 PostsLatest Activity: 7 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!