8-Mavzu: berilganlar oqimi. Fayl tizimi bilan ishlash sinflari. Ma’ruza rejasi


Download 19.29 Kb.
bet2/2
Sana18.10.2023
Hajmi19.29 Kb.
#1707593
1   2
Bog'liq
29-maruza

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());
}
}
}
}
Download 19.29 Kb.

Do'stlaringiz bilan baham:
1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling