Search code examples
c#winformsvisual-studio-2010openfiledialogfolderbrowserdialog

How to specifiy rootfolder with openFileDialog


With folderBrowseDialog you can show the top level of the folder which will be shown initially. However that feature is not there on openFileDialog.

I want to let the user open files from a specific folder only. How do I specify the folder?


Solution

  • Just set the openFileDialog.InitialDirectory

    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.InitialDirectory = @"C:\";
    openFileDialog.ShowDialog();