Exemple #1
0
        private static void DatCount(string datRoot, string subPath)
        {
            DirectoryInfo di = new DirectoryInfo(Path.Combine(datRoot, subPath));

            DirectoryInfo[] dis = di.GetDirectories();
            foreach (DirectoryInfo d in dis)
                DatCount(datRoot, Path.Combine(subPath, d.Name));

            FileInfo[] fis = di.GetFiles("*.DAT");
            _datCount += fis.Length;

            fis = di.GetFiles("*.XML");
            _datCount += fis.Length;
        }
Exemple #2
0
        private static void ReadDats(uint ParentId, string datRoot, string subPath)
        {
            DirectoryInfo di = new DirectoryInfo(Path.Combine(datRoot, subPath));

            DirectoryInfo[] dis = di.GetDirectories();
            foreach (DirectoryInfo d in dis)
            {
                uint DirId = FindOrInsert.FindOrInsertIntoDir(ParentId, d.Name, Path.Combine(subPath, d.Name) + "\\");
                ReadDats(DirId, datRoot, Path.Combine(subPath, d.Name));
                if (_bgw.CancellationPending)
                    return;
            }

            FileInfo[] fis = di.GetFiles("*.DAT");
            ReadDat(fis, subPath, ParentId);

            fis = di.GetFiles("*.XML");
            ReadDat(fis, subPath, ParentId);
        }
Exemple #3
0
        public DirectoryInfo[] GetDirectories(string SearchPattern, bool includeHidden = true)
        {
            List<DirectoryInfo> dirs = new List<DirectoryInfo>();

            string dirName = NameFix.AddLongPathPrefix(FullName);

            Win32Native.WIN32_FIND_DATA findData = new Win32Native.WIN32_FIND_DATA();
            SafeFindHandle findHandle = Win32Native.FindFirstFile(dirName + @"\" + SearchPattern, findData);

            if (!findHandle.IsInvalid)
            {
                do
                {
                    string currentFileName = findData.cFileName;

                    // if this is a directory, find its contents
                    if ((findData.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY) == 0) continue;
                    if (currentFileName == "." || currentFileName == "..") continue;
                    if (!includeHidden && (findData.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_HIDDEN) != 0) continue;

                    DirectoryInfo di = new DirectoryInfo
                    {
                        Name = currentFileName,
                        FullName = Path.Combine(FullName, currentFileName),
                        LastWriteTime = Convert.Time(findData.ftLastWriteTimeHigh, findData.ftLastWriteTimeLow),
                        fileAttributes = findData.dwFileAttributes
                    };
                    dirs.Add(di);
                }
                while (Win32Native.FindNextFile(findHandle, findData));
            }

            // close the find handle
            findHandle.Dispose();

            return dirs.ToArray();
        }