.net - C# OpenFileDialog for getting a user-selected output path for a Windows form? -


good morning,

i'm trying figure out how use openfiledialog function in c# allow user select desired output folder. right have button , textbox on windows form. user hit button, , open dialog gui @ run-time allow user navigate the output location, hit ok. should have confirmation of selection having path displayed in textbox.

the code have right follows:

      private void button1_click_3(object sender, eventargs e)     {         openfiledialog outputfilepath = new openfiledialog();          string outputstring = outputfilepath.filename;         filepathbox.text = outputstring;      } 

it compiles fine, when hit button, doesn't bring file dialog box.

i'm sure it's simple i'm not seeing?

thanks in advance!

~andrew

you need show dialog , check dialogresult because user can click cancel

openfiledialog outputfilepath = new openfiledialog(); var res = outputfilepath.showdialog(); if (res == dialogresult.ok) {     string outputstring = outputfilepath.filename;     filepathbox.text = outputstring; } 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -