Esempio n. 1
0
        private static void PopulateFolders(string dirName, Folder parentFolder)
        {
            string[] folderItems = Directory.GetFileSystemEntries(dirName);

            foreach (var folderItem in folderItems)
            {
                // If the current node is a filename, don't call recursion and continue
                try
                {
                    Directory.GetDirectories(folderItem);
                }
                catch (IOException ex)
                {
                    FileInfo finfo = new FileInfo(folderItem);
                    FileItem fileSubItem = new FileItem(folderItem, finfo.Length);
                    parentFolder.AddFile(fileSubItem);
                    continue;
                }
                // Some windows folders could be restricted, so just output a warning message and continue
                catch (UnauthorizedAccessException)
                {
                    Console.WriteLine("Warning: No access to folder {0}", dirName);
                    continue;
                }

                Folder folderSubItem = new Folder(folderItem, true);
                parentFolder.AddFolder(folderSubItem);

                PopulateFolders(folderItem, folderSubItem);
            }
        }
Esempio n. 2
0
 /* ----------------------
  *      METHODS
  * -------------------- */
 public void AddFile(FileItem newFile)
 {
     this.files.Add(newFile);
 }
Esempio n. 3
0
 /* ----------------------
 *      METHODS
 * -------------------- */
 public void AddFile(FileItem newFile)
 {
     this.files.Add(newFile);
 }