public override TextWriter CreateTextWriter(string directory, string name, string extension) { // Note: extension can be null. ArgumentUtility.CheckNotNull("directory", directory); ArgumentUtility.CheckNotNull("name", name); var textWriterData = new TextWriterData(new StringWriter(), directory, extension); NameToTextWriterData[name] = textWriterData; return(textWriterData.TextWriter); }
public override TextWriter CreateTextWriter(string directory, string name, string extension) { ArgumentUtility.CheckNotNull("directory", directory); ArgumentUtility.CheckNotNull("name", name); if (!System.IO.Directory.Exists(directory)) { System.IO.Directory.CreateDirectory(directory); } if (NameToTextWriterData.ContainsKey(name)) { throw new ArgumentException(string.Format("TextWriter with name \"{0}\" already exists.", name)); } string nameWithExtension = AppendExtension(name, extension); var textWriterData = new TextWriterData(new StreamWriter(Path.Combine(directory, nameWithExtension)), directory, extension); NameToTextWriterData[name] = textWriterData; return(textWriterData.TextWriter); }