Esempio n. 1
0
        /// <summary>
        /// Scan directory information into the directory ArrayList.
        /// </summary>
        public virtual void DirList(string psQualifier, ref long pnEstimate)
        {
            InitializeCounts();
            ArrayList oDirs      = new ArrayList();
            string    sDirectory = "";
            long      nCount;
            long      nEntries;

            SignalBeginProgress("DirList");
            try
            {
                //Build directory and file list.
                oDirs       = new ArrayList();
                psQualifier = psQualifier.Trim();
                psQualifier = R.Strip(psQualifier, "TRAILING", @"\");
                oDirs.Add(psQualifier);
                pnEstimate = 1;
                nCount     = 1;
                nEntries   = oDirs.Count;
                while (nCount <= nEntries)
                {
                    sDirectory = oDirs[(int)nCount - 1].ToString();
                    DirLevel(psQualifier, sDirectory, ref oDirs, ref pnEstimate);
                    nCount   = nCount + 1;
                    nEntries = oDirs.Count;
                }
            }
            catch (Exception oException)
            {
                Console.WriteLine(oException.Message);
            }
            finally
            {
                FinalizeCounts();
                SignalEndOfProgress("DirList");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Append directory level information into the specified recordset.
        /// </summary>
        public void DirLevel(string psQualifier, string psDirectory, ref ArrayList poDirs, ref long pnEstimate)
        {
            string sSpec;
            string sPath;
            string sName;

            sPath = psDirectory;
            if (psDirectory.Length > psQualifier.Length)
            {
                psDirectory = psDirectory.Substring(psQualifier.Length);
            }
            else
            {
                psDirectory = string.Empty;
            }
            try
            {
                DirectoryInfo oDirectory = new DirectoryInfo(sPath);
                oDirectory.Refresh();
                DirectoryInfo[] aDirs = oDirectory.GetDirectories();
                for (int nRow = 0; nRow < aDirs.Length; nRow++)
                {
                    try
                    {
                        sName = aDirs[nRow].Name;
                        sSpec = sPath + "\\" + sName;
                        if (aDirs[nRow].Exists)
                        {
                            poDirs.Add(sSpec);
                            pnEstimate += 1;
                            SignalUpdateProgress("DirList");
                        }
                    }
                    catch (Exception oExceptionA)
                    {
                        Console.WriteLine(oExceptionA.Message);
                    }
                }
                FileInfo[] aFiles = oDirectory.GetFiles();
                for (int nRow = 0; nRow < aFiles.Length; nRow++)
                {
                    try
                    {
                        sName = aFiles[nRow].Name;
                        sSpec = sPath + "\\" + sName;
                        if (aFiles[nRow].Exists)
                        {
                            string sContents = R.ReadFile(sSpec);
                            Classify(aFiles[nRow], R.TextRows(sContents));
                            pnEstimate += 1;
                            SignalUpdateProgress("DirList");
                        }
                    }
                    catch (Exception oExceptionB)
                    {
                        Console.WriteLine(oExceptionB.Message);
                    }
                }
            }
            catch (Exception oExceptionD)
            {
                Console.WriteLine(oExceptionD.Message);
            }
            finally
            {
            }
        }