Esempio n. 1
0
        public List <IFileEntry> List()
        {
            try
            {
                var list = new List <IFileEntry>();
                var lfr  = dbx.ListFiles(m_path);

                foreach (var md in lfr.entries)
                {
                    list.Add(ParseEntry(md));
                }

                while (lfr.has_more)
                {
                    lfr = dbx.ListFilesContinue(lfr.cursor);
                    foreach (var md in lfr.entries)
                    {
                        list.Add(ParseEntry(md));
                    }
                }

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

                throw;
            }
        }
Esempio n. 2
0
        public IEnumerable <IFileEntry> List()
        {
            var lfr = HandleListExceptions(() => dbx.ListFiles(m_path));

            foreach (var md in lfr.entries)
            {
                yield return(ParseEntry(md));
            }

            while (lfr.has_more)
            {
                lfr = HandleListExceptions(() => dbx.ListFilesContinue(lfr.cursor));
                foreach (var md in lfr.entries)
                {
                    yield return(ParseEntry(md));
                }
            }
        }
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;
                }
            }
        }