public Write ( byte array, int offset, int count ) : void | ||
array | byte | |
offset | int | |
count | int | |
return | void |
using System.IO; string filePath = "data.txt"; using (FileStream fileStream = new FileStream(filePath, FileMode.Append)) { byte[] data = Encoding.UTF8.GetBytes("Hello World!"); fileStream.Write(data, 0, data.Length); }
using System.IO; string filePath = "data.txt"; using (StreamWriter streamWriter = new StreamWriter(filePath)) { streamWriter.Write("Hello World!"); }In this example, we use the StreamWriter class to write a string to a file. We create a new StreamWriter object with a file path and call the Write method to write the data to the file. The System.IO namespace is part of the .NET Standard Library.
public Write ( byte array, int offset, int count ) : void | ||
array | byte | |
offset | int | |
count | int | |
return | void |