फ़ाइल संचालन जैसे पढ़ने और लिखने के लिए एक स्ट्रीम FileStream वर्ग द्वारा प्रदान की जाती है।
इस तरह एक वस्तु बनाएं
FileStream fstream = new FileStream("d:\\new.txt", FileMode.OpenOrCreate); ऊपर हमने FileMode.OpenOrCreate का उपयोग किया है ताकि फ़ाइल को खोला या बनाया जा सके यदि यह पहले से मौजूद नहीं है।
निम्नलिखित n उदाहरण दिखा रहा है कि C# में FileStream वर्ग का उपयोग कैसे करें -
using System;
using System.IO;
public class Demo {
public static void Main(string[] args) {
FileStream fstream = new FileStream("d:\\new.txt", FileMode.OpenOrCreate);
// write into the file
fstream.WriteByte(90);
// close the file
fstream.Close();
}
}