Click or drag to resize

FileInfoAppendText Method

Creates a StreamWriter that appends text to the file represented by this instance of the FileInfo.

Namespace: Crestron.SimplSharp.CrestronIO
Assembly: SimplSharpHelperInterface (in SimplSharpHelperInterface.dll) Version: 2.21.121
Syntax
C#
public StreamWriter AppendText()

Return Value

StreamWriter
A new StreamWriter.
Example
using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronIO;; class Test { public static void Main() { FileInfo fi = new FileInfo(@"\user\MyTest.txt"); // This text is added only once to the file. if (!fi.Exists) { //Create a file to write to. using (StreamWriter sw = fi.CreateText()) { sw.WriteLine("Hello"); sw.WriteLine("And"); sw.WriteLine("Welcome"); } } // This text will always be added, making the file longer over time // if it is not deleted. using (StreamWriter sw = fi.AppendText()) { sw.WriteLine("This"); sw.WriteLine("is Extra"); sw.WriteLine("Text"); } } }

Version Information

.NET

Supported in: 6.0

.NET Compact Framework

Supported in: 3.5
See Also