예제 #1
0
        void reserveFileForBackupImage()
        {
            _log.ProcedureCall("reserveFileForBackupImage");

            string templateFileName = Path.Combine(Directories.TempFolder,
                                                   "Backup{0}-" + DateTime.Now.ToString("dddd - dd - MMMM.yyyy HH.mm.ss", CultureInfo.InvariantCulture) + Files.ImageFilesExtension);

            for (int id = 0; id < Int32.MaxValue; id++)
            {
                string fileName;
                if (id > 0)
                {
                    fileName = string.Format(templateFileName, id, CultureInfo.InvariantCulture);
                }
                else
                {
                    fileName = string.Format(templateFileName, string.Empty, CultureInfo.InvariantCulture);
                }

                if (_imageFile.TrySyncFile(fileName))
                {
                    return;
                }
            }

            throw new InvalidOperationException("Fatal Error: could not reserve file name");
        }
예제 #2
0
        /// <exception cref="LogException">Synchronization failled</exception>
        public FileLog(string logsFolder, LogLevel level, bool consoleApp) : base(level, LogMode.File, consoleApp)
        {
            if (string.IsNullOrEmpty(logsFolder))
            {
                throw new ArgumentNullException("logsFolder");
            }

            try
            {
                do
                {
                    do
                    {
                        _fileName = Path.Combine(logsFolder,
                                                 DateTime.Now.ToString(_TIME_FORMATSTRING, CultureInfo.CurrentCulture) +
                                                 Files.LogFilesExtension);
                    }while (File.Exists(_fileName));
                }while (!_syncfile.TrySyncFile(_fileName));
            }
            catch (ArgumentException e)
            {
                throw new LogException(e.Message);
            }
        }