The FileStream class provides streams for file operations such as reading and writing.
Create an object like this
FileStream fstream = new FileStream("d:\ew.txt", FileMode.OpenOrCreate);
Above we used FileMode.OpenOrCreate to open or create a file (if the file does not exist yet).
The following example shows how to use the FileStream class in C# -
using System; using System.IO; public class Demo { public static void Main(string[] args) { FileStream fstream = new FileStream("d:\ew.txt", FileMode.OpenOrCreate); // write into the file fstream.WriteByte(90); // close the file fstream.Close(); } }
The above is the detailed content of How to use C# FileStream class?. For more information, please follow other related articles on the PHP Chinese website!