const string ExFile = "Example.cfg";
public static void Main()
{
if (File.Exists(ExFile))
{
Console.WriteLine("{0} Уже существует!",ExFile);
return;
}
using (FileStream fs = new FileStream(ExFile, FileMode.CreateNew))
{
using (BinaryWriter BW = new BinaryWriter(fs))
{
for (int i = 0; i < 9; i++)
{
BW.Write(i);
}
}
}
using (FileStream fs = new FileStream(ExFile, FileMode.Open, FileAccess.Read))
{
using (BinaryReader BR = new BinaryReader(fs))
{
for (int i = 0; i < 9; i++)
{
Console.WriteLine(BR.ReadInt32());
}
}
}
}
Do'stlaringiz bilan baham: |