cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Known issues updated. Learn more
Highlighted
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);
                }
            }
        }

 

1 Accepted best answer

Accepted Solutions
Dropboxer

Re: Download error - path not found (.NET)

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".

Reply
Loading...
4 Replies
Dropboxer

Re: Download error - path not found (.NET)

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.)

Reply
Loading...
Level 4

Re: Download error - path not found (.NET)

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")

Reply
Loading...
Dropboxer

Re: Download error - path not found (.NET)

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".

Reply
Loading...
Level 4

Re: Download error - path not found (.NET)

Using PathLower doesn't seem to make a difference but I'll use it anyways just to be safe.

 

Setting the PathRoot to HomeNamespaceId allows me to download files from my personal user folder.

Setting PathRoot to RootNamespaceId lets me download from the root (where it shows my personal folder and my business team folder) but I can't download files from the Team folder (path not found).

 

I'm wondering if I can continue to use a DropboxClient, Dropbox App vs Dropbox Business App and API, and what PathRoot I should be setting to access team files?

 

 

**EDIT**:

May actually be on to something - I think I was setting the wrong namespace/Pathroot when I was calling the download function. I think if I set the client Pathroom to home, I can download personal user files just fine. And if I set it to root, I can download team files fine. Let me test a bit more..

Reply
Loading...
Who's talking
Top contributors to this post