Create FileStream from FileInfo
using System;
using System.IO;
class FileFileInfoApp
{
static void Main(string[] args)
{
FileInfo f = new FileInfo("Bar.txt");
FileStream fs = f.Create();
StreamWriter w = new StreamWriter(fs);
w.Write("Hello World");
w.Close();
fs = f.Open(FileMode.Open, FileAccess.Read, FileShare.None);
StreamReader r = new StreamReader(fs);
string t;
while ((t = r.ReadLine()) != null){
Console.WriteLine(t);
}
w.Close();
fs.Close();
f.Delete();
}
}
Related examples in the same category