You are here

4 May 2012

How to create file browser dialogue in Microsoft Visual C#.

Source code viewer
  1. OpenFileDialog fd = new OpenFileDialog(); // create new file dialog
  2. fd.Filter = "CSV|*.csv"; // allow csv file only
  3. fd.InitialDirectory = input_file_dir.Text; // load same dir on second load
  4. fd.ShowDialog(); // show user the dialog
  5. if (fd.FileName.Length > 1) // so that if you press cancel second time, the dir won't be erazed
  6. input_file_dir.Text = fd.FileName; // write the file dir to somewhere, I used label
Programming Language: C#