FileInfo.Open : FileInfo « System.IO « C# / C Sharp by API






FileInfo.Open

 

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

1.new FileInfo(String fileName)
2.FileInfo.Attributes
3.FileInfo.Create()
4.FileInfo.CreationTime
5.FileInfo.CopyTo(String fileName)
6.FileInfo.Delete
7.FileInfo.Directory
8.FileInfo.FullName
9.FileInfo.LastAccessTime
10.FileInfo.MoveTo(String path)
11.FileInfo.OpenRead
12.FileInfo.OpenText
13.FileInfo.OpenWrite()