Append to the end of file when "write"
am 15.10.2007 04:55:22 von Fir5tSightI want to write to an output file, "C:\\temp\\debug.txt": If the file
exists, append the new content to the end of the file (instead of
overwriting the current content). If the file doesn't exist, create
the file and write from the beginning.
Therefore, I want to code this like below:
FileInfo lFile = new FileInfo("C:\\temp\\debug.txt");
if (lFile.Exists)
{
// What's the syntax to append new content (instead of
overwriting the existing content?
FileStream lStream =
lFile.Open(FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
}
else
{
FileStream lStream =
lFile.Open(FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
}
I believe the append mode is defined at the "lFile.Open" line with the
correct parameters. Thanks!