Beispiel #1
0
        private void IndexInEachDir(IndexerAdapter myReader)
        {
            string where = null;
            List<string> folderList = new List<string>();
            folderList = myReader.GetConfig().FolderList;
            TreeNetIndexer treeNetLib = new TreeNetIndexer(myReader);

            string ext = myReader.GetConfig().IndexFileExt;

            for (int i = 0; i <= myReader.GetConfig().FolderList.Count - 1; i++)
            {
                string strDirPath = myReader.GetConfig().FolderList[i];
                // 2.5.1.1 Indexer halted if a configuration file had non-existent folders paths
                if (Directory.Exists(strDirPath))
                {
                    where = myReader.fGetIndexFilePath(i, IndexingMode.IN_EACH_DIRECTORY);
                    if (Directory.Exists(Path.GetDirectoryName(where)) == false)
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(where));
                    }

                    StreamWriter sw = new StreamWriter(where, false);
                    StringBuilder sb = new StringBuilder();
                    try
                    {
                        this.CurrentDirMessage = "Indexing " + strDirPath;

                        if (ext.Contains("html"))
                        {
                            //MessageBox.Show(myReader.GetConfig().mCssFilePath)
                            treeNetLib.mBooFirstIndexFile = true;
                            treeNetLib.IndexRootFolderToHtml(strDirPath, sb, mSettings.GetConfig().AddFooter);
                        }
                        else
                        {
                            treeNetLib.IndexFolderToTxt(strDirPath, sb, mSettings.GetConfig().AddFooter);
                        }

                        this.Progress += 1;
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        MessageBox.Show(ex.Message + "\n" + "Please Run TreeGUI As Administrator or Change Output Directory.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK);
                        return;
                    }
                    finally
                    {
                        sw.Write(sb.ToString());
                        sw.Close();
                    }

                    // Zip after sw is closed
                    if (myReader.GetConfig().ZipFilesInEachDir)
                    {
                        myReader.ZipAdminFile(where, null);
                    }
                }
            }
        }