Call ShowDialog() to display an OpenFileDialog

image_pdfimage_print
   
 

using System;
using System.Windows.Forms;

class MainClass {
    static void Main(string[] args) {

        OpenFileDialog dlg = new OpenFileDialog();

        if (dlg.ShowDialog() == DialogResult.OK) {
            Console.WriteLine(dlg.FileName);

        }
    }
}