Esempio n. 1
0
        public ListFolderResult ListFilesContinue(String cursor)
        {
            ListFolderContinueArg lfca = new ListFolderContinueArg();

            lfca.cursor = cursor;

            var url = string.Format("{0}/files/list_folder/continue", API_URL);

            try
            {
                ListFolderResult lfr = PostAndGetJSONData <ListFolderResult>(url, lfca);
                return(lfr);
            }
            catch (Exception ex)
            {
                handleDropboxException(ex);
                throw;
            }
        }
Esempio n. 2
0
        public ListFolderResult ListFiles(string path)
        {
            PathArg pa = new PathArg();

            pa.path = path;

            var url = string.Format("{0}/files/list_folder", API_URL);

            try
            {
                ListFolderResult lfr = PostAndGetJSONData <ListFolderResult>(url, pa);
                return(lfr);
            }
            catch (Exception ex)
            {
                handleDropboxException(ex);
                throw;
            }
        }
Esempio n. 3
0
        public List <IFileEntry> List()
        {
            try
            {
                ListFolderResult lfr = dbx.ListFiles(m_path);


                List <IFileEntry> list = new List <IFileEntry>();

                foreach (MetaData md in lfr.entries)
                {
                    FileEntry ife = new FileEntry(md.name);
                    if (md.IsFile)
                    {
                        ife.IsFolder = false;
                        ife.Size     = (long)md.size;
                    }
                    else
                    {
                        ife.IsFolder = true;
                    }

                    list.Add(ife);
                }
                if (lfr.has_more)
                {
                    do
                    {
                        lfr = dbx.ListFilesContinue(lfr.cursor);

                        foreach (MetaData md in lfr.entries)
                        {
                            FileEntry ife = new FileEntry(md.name);
                            if (md.IsFile)
                            {
                                ife.IsFolder = false;
                                ife.Size     = (long)md.size;
                            }
                            else
                            {
                                ife.IsFolder = true;
                            }

                            list.Add(ife);
                        }
                    } while (lfr.has_more);
                }

                return(list);
            }
            catch (DropboxException de)
            {
                if (de.errorJSON["error"][".tag"].ToString() == "path")
                {
                    if (de.errorJSON["error"]["path"][".tag"].ToString() == "not_found")
                    {
                        throw new FolderMissingException();
                    }
                    else
                    {
                        throw;
                    }
                }
                else
                {
                    throw;
                }
            }
        }