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(); } }
以上就是如何使用C# FileStream类?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号