C# StreamWriter StreamWriter(String)
Description
StreamWriter StreamWriter(String)
Initializes a new
instance of the StreamWriter class for the specified file by using the default
encoding and buffer size.
Syntax
StreamWriter.StreamWriter(String)
has the following syntax.
public StreamWriter(
string path
)
Parameters
StreamWriter.StreamWriter(String)
has the following parameters.
path
- The complete file path to write to. path can be a file name.
Example
The following code example demonstrates this constructor.
/* w w w . j a va 2s . co m*/
using System;
using System.IO;
using System.Text;
class Program
{
static void Main(string[] args)
{
string fileName = "test.txt";
string textToAdd = "java2s.com";
using (StreamWriter writer = new StreamWriter(fileName))
{
writer.Write(textToAdd);
}
}
}