今天进行了C#的第五次学习,继续了解C#的相关知识:
目录文件的输入与输出
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();
}
}
}
标签:C#,System,学习,FileStream,using,第七天
From: https://www.cnblogs.com/lht020321/p/16792014.html