FileOk Action : Open File Dialog : GUI Windows Form C# Source Code


Custom Search

C# Source Code » GUI Windows Form » Open File Dialog »

 

FileOk Action








    
 
using System;
using System.IO;
using System.Windows.Forms;

class FileDialogApp {
    private static OpenFileDialog ofd;

    static void Main(string[] args) {
        ofd = new OpenFileDialog();
        string s = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()));

        ofd.InitialDirectory = s;
        ofd.FileOk += new System.ComponentModel.CancelEventHandler(ofd_OK);
        ofd.ShowDialog();
    }
    public static void ofd_OK(object sender,
        System.ComponentModel.CancelEventArgs e) {
        StreamReader sr = new StreamReader(ofd.FileName);
        string s;
        while ((s = sr.ReadLine()) != null) {
            Console.WriteLine(s);
        }
        sr.Close();
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo GUI Windows Form
» Open File Dialog