private StreamWriter GetLogWriter(IFileStorage storage) { string fileToUse; if (!storage.FileExists(FILE1_NAME) || storage.GetFileSize(FILE1_NAME) < MAX_LOG_FILE_SIZE) { fileToUse = FILE1_NAME; } else if (!storage.FileExists(FILE2_NAME) || storage.GetFileSize(FILE2_NAME) < MAX_LOG_FILE_SIZE) { fileToUse = FILE2_NAME; } else { storage.DeleteFileIfExists(FILE1_NAME); storage.RenameFile(FILE2_NAME, FILE1_NAME); fileToUse = FILE2_NAME; } return storage.OpenWriter(fileToUse, true); }