2024-11-20《文件的输入与输出》
文件的输入与输出
I/O类

FileStream类



下面是一个FileSteam类的操作示例:
| using System; | |
| using System.IO; | |
| namespace FileIOApplication | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| FileStream F = new FileStream("test.dat", | |
| FileMode.OpenOrCreate, FileAccess.ReadWrite); | |
| for (int i = 1; i <= 20; i++) | |
| { | |
| F.WriteByte((byte)i); | |
| } | |
| F.Position = 0; | |
| for (int i = 0; i <= 20; i++) | |
| { | |
| Console.Write(F.ReadByte() + " "); | |
| } | |
| F.Close(); | |
| Console.ReadKey(); | |
| } | |
| } | |
| } |
浙公网安备 33010602011771号