internal static void Save()
{
if ( !IsLoaded )
return;
Logger.Log( LogType.Debug,
"IPBanList.Save: Saving IP ban list ({0} records).", Bans.Count );
const string tempFile = Paths.IPBanListFileName + ".temp";
lock ( BanListLock ) {
using ( StreamWriter writer = File.CreateText( tempFile ) ) {
writer.WriteLine( "{0} {1}", FormatVersion, Header );
foreach ( IPBanInfo entry in Bans.Values ) {
writer.WriteLine( entry.Serialize() );
}
}
}
try {
Paths.MoveOrReplace( tempFile, Paths.IPBanListFileName );
} catch ( Exception ex ) {
Logger.Log( LogType.Error,
"IPBanList.Save: An error occured while trying to save ban list file: {0}", ex );
}
}