Exemple #1
0
        private TBookCollection _getFiles(DirectoryInfo oDirectory)
        {
            TBookCollection oRetVal = new TBookCollection();

            foreach (string sExtension in _extensions)
            {
                foreach (FileInfo oFileInfo in oDirectory.GetFiles("*." + sExtension))
                {
                    oRetVal.Add(new TBook(oFileInfo.Name, Path.GetDirectoryName(oDirectory.FullName), TBook.BookTypeEnum.Pdf));
                }
            }
            return(oRetVal);
        }
Exemple #2
0
        private TBookCollection _getSubDirs(string pathname, BackgroundWorker worker, double percentage, int level)
        {
            TBookCollection CurrentBookList = new TBookCollection();
            DirectoryInfo   oDirInfo        = new DirectoryInfo(pathname);

            foreach (DirectoryInfo oSubDirectoryInfo in oDirInfo.GetDirectories())
            {
                CurrentFolder = oSubDirectoryInfo.FullName;
                worker.ReportProgress((int)percentage, oSubDirectoryInfo.FullName);
                try {
                    if (oSubDirectoryInfo.Attributes != FileAttributes.System && oSubDirectoryInfo.GetDirectories().Length > 0)
                    {
                        Trace.WriteLine(oSubDirectoryInfo.FullName, "trace");
                        CurrentBookList.AddRange(_getSubDirs(oSubDirectoryInfo.FullName, worker, percentage, level + 1));
                    }
                    if (oSubDirectoryInfo.Attributes != FileAttributes.System && oSubDirectoryInfo.GetFiles().Length > 0)
                    {
                        if ((oSubDirectoryInfo.GetFiles("thumbs.db", SearchOption.TopDirectoryOnly).Length == 1) && (oSubDirectoryInfo.GetFiles().Length == 1))
                        {
                            // skip folder
                        }
                        else
                        {
                            CurrentBookList.Add(new TBook(oSubDirectoryInfo.Name, Path.GetDirectoryName(oSubDirectoryInfo.FullName)));
                            CurrentBookList.AddRange(_getFiles(oSubDirectoryInfo));
                        }
                    }
                    if (level == 0)
                    {
                        percentage++;
                    }
                } catch (Exception ex) {
                    Trace.WriteLine(string.Format("Error : {0}", ex.Message));
                }
            }
            return(CurrentBookList);
        }