This CSharp (C#) code snippet demonstrates how to let the user select a filename with the OpenFileDialog control.

 

private void OpenFileDialog_Example()
{
    OpenFileDialog myOpenFileDialog = new OpenFileDialog();

    // optional filter to restrict file types
    myOpenFileDialog.Filter = "CSV Files|*.csv";

    if (myOpenFileDialog.ShowDialog() == DialogResult.OK)
    {
        string selectedFileName = myOpenFileDialog.FileName;

        // do whatever you like with the selected filename
    }
}
This website is making use of cookies for website analysis. Data is collected anonymously and solely for the purpose of improving the website. Do you agree to the use of cross-session cookies?