如何使用 C# FileStream 类?
FileStream 类提供了一个用于文件操作(诸如读取和写入)的流。
创建如下对象
FileStream fstream = new FileStream("d:\
ew.txt", FileMode.OpenOrCreate);以上内容使用了 FileMode.OpenOrCreate,以便在文件不存在时打开或创建文件。
以下示例展示如何在 C# 中使用 FileStream 类 −
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();
}
}
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP