Beispiel #1
0
        private void ForceAutoSave()
        {
            FControlFileStream.Flush();
            FFileStream.Flush();

            Stream textStream      = (FFileStream as StreamWriter).BaseStream;
            String recycleFilePath = FileHelper.RecycleAndGetNextFileName(FFilePath, FAutoSave, FFileHeader);

            using (FileStream recycleStream = FileStreamAccess.OpenFileStreamForWriting(recycleFilePath, FileMode.Create))
            {
                RIUtils.CopyFile(textStream, recycleStream);
            }

            // truncate text file
            textStream.SetLength(0);
            textStream.Seek(0, SeekOrigin.End);
            FFileStream.Flush();

            // trucate control file
            FControlFileStream.SetLength(0);
            FControlFileStream.Seek(0, SeekOrigin.End);
            FControlFileStream.Flush();

            FFileHeader = FileHelper.ReadHeader(FControlFileStream, FControlFilePath, null);
            FControlFileStream.Seek(0, SeekOrigin.End);
        }
        private void ForceAutoSave()
        {
            // write header and flush all buffers
            FileHelper.WriteHeader(FFileStream, FFileHeader);
            FFileStream.Flush();

            String recycleFilePath = FileHelper.RecycleAndGetNextFileName(FFilePath, FAutoSave, FFileHeader);

            using (FileStream recycleStream = FileStreamAccess.OpenFileStreamForWriting(recycleFilePath, FileMode.Create))
            {
                RIUtils.CopyFile(FFileStream, recycleStream);
            }

            // trucate the file
            FFileStream.SetLength(0);
            FFileStream.Flush();

            FFileHeader = FileHelper.ReadHeader(FFileStream, FFilePath, null);
            FFileStream.Seek(0, SeekOrigin.End);
        }