コード例 #1
0
        private void ReplaceDb(string pathToDbFile, ILogWriter applicationLog, Exception exception)
        {
            string backupFileName = string.Format(
                "{0}_{1}.invalid",
                pathToDbFile,
                DateTime.UtcNow.ToString("yyyy-MM-ddThh-mm-ss"));

            File.Copy(pathToDbFile, backupFileName);

            File.Delete(pathToDbFile);

            this.CreateNewDb(pathToDbFile);

            applicationLog.AddEntry(
                new LogEntry(
                    MessageLevel.Warning,
                    ClassName,
                    string.Format(
                        "Invalid database file found at {0}. Replacement file created.{1}Error:{2}",
                        pathToDbFile,
                        Environment.NewLine,
                        exception.Message)));
        }