public void RedirectErr(TextWriter sw) { if (sw != null) { Err.Redirect(sw); _errorWriter = sc.Error; sc.SetError(sw); IsErrorRedirected = true; } else { Err.Redirect((TextWriter)null); sc.SetError(_errorWriter); _errorWriter = null; IsErrorRedirected = false; } }
public void RedirectErr(string filepath = null) { if (filepath != null) { _errorWriter = sc.Error; _errorFileStream = new FileStream(filepath, FileMode.Append, FileAccess.Write); _errorStreamWriter = new StreamWriter(_errorFileStream); sc.SetOut(_errorStreamWriter); Err.Redirect(_errorStreamWriter); } else { _errorStreamWriter.Flush(); _errorStreamWriter.Close(); _errorStreamWriter = null; sc.SetOut(_errorWriter); _errorWriter = null; Err.Redirect((string)null); } }