Beispiel #1
0
        public void Close()
        {
            //_HeadFile.Close();
            _DDXFile.Close();

            //_IndexFile.Close();
            _IDXFile.Close();
        }
Beispiel #2
0
        private void TransferHeadFiles()
        {
            //Get .hdx files in the index folder
            string[] files = System.IO.Directory.GetFiles(_Path, "???????" + FieldName + ".hdx");

            //Transfer .hdx to .ddx file
            foreach (string file in files)
            {
                string fileName = System.IO.Path.GetFileName(file);
                int    serial   = int.Parse(fileName.Substring(0, 7));

                string ddxFileName = Path.AppendDivision(_Path, '\\') +
                                     GetDDXFileName(serial);

                if (Hubble.Framework.IO.File.GetFileLength(file) <= 0)
                {
                    System.IO.File.Delete(file);
                    continue;
                }

                if (System.IO.File.Exists(ddxFileName))
                {
                    System.IO.File.Delete(ddxFileName);
                }

                using (System.IO.FileStream hFile = new System.IO.FileStream(file, System.IO.FileMode.Open,
                                                                             System.IO.FileAccess.Read, System.IO.FileShare.Read))
                {
                    using (DDXFile ddxFile = new DDXFile(ddxFileName, DDXFile.Mode.Write))
                    {
                        foreach (IndexFile.WordFilePosition wfp in GetWordFilePositionList(hFile, serial))
                        {
                            ddxFile.Add(wfp.Word, wfp.Position.Position, wfp.Position.Length);
                        }

                        ddxFile.Close();
                    }
                }

                string bakFile = Path.AppendDivision(_Path, '\\') + GetHeadBakFileName(serial);

                if (System.IO.File.Exists(bakFile))
                {
                    System.IO.File.Delete(bakFile);
                }

                System.IO.File.Move(file, bakFile);
            }
        }