c# - Can I launch DotNet's OpenFileDialog in C:\Users\Public\Documents? -


is there way launch openfiledialog in c:\users\public\documents folder?

i writing c# application, using dotnet framework. trying launch openfiledialog, initialdirectory of "c:\\users\\public\\documents\\" , filename of "world.txt". unfortunately, openfiledialog putting me in documents shortcut instead of c:\users\public\documents .

expected results
expect see openfiledialog open, top textbox showing > pc > windows7_os (c:) > users > public > documents , bottom textbox showing world.txt . expect if click in top textbox, show c:\users\public\documents .

actual results
openfiledialog opens. top textbox shows > pc > documents , bottom textbox shows world.txt . if click in top textbox, shows documents . displayed folder contents not same contents of c:\users\public\documents .

things have tried
have stopped code in visual studio debugger after following line of code:
openfiledialog dlg = new openfiledialog();

in immediate window, have executed code such following:

dlg.filename = "world.txt"   ? dlg.filename   dlg.initialdirectory = "c:\\nonexistentdirectory\\";   dlg.showdialog();   dlg.initialdirectory = "c:\\";   dlg.showdialog();   dlg.initialdirectory = "c:\\users\\";   dlg.showdialog();  dlg.initialdirectory = "c:\\users\\public\\";   dlg.showdialog();  dlg.initialdirectory = "c:\\users\\public\\documents\\";   dlg.showdialog();   

i cancel out of each dialog.

i used c:\windows\system32\cmd.exe cd between c:\ , c:\users\ , c:\users\public , c:\users\public\documents\ .

results of things have tried

  • when dlg.initialdirectory = "c:\\nonexistentdirectory\\" , dialog's folder displays this pc > documents > visual studio 2015 > projects > simplegame > controller > bin > debug" . clicking in textbox causes display c:\users\owner\documents\visual studio 2015\projects\simplegame\controller\bin\debug . therefore assume openfiledialog silently handles invalid initialdirectory not changing directories. in case, defaulting project's assembly's bin's debug folder.

  • when dlg.initialdirectory "c:\\" or "c:\\users\\" or "c:\\users\\public\\" dialog behaves expected. clicking in top textbox produces c:\ or c:\users or c:\users\public respectively.

  • when dlg.initialdirectory = "c:\\users\\public\\documents\\" dialog behaves incorrectly. top textbox shows > pc > documents , bottom textbox shows world.txt . if click in top textbox, shows documents . displayed folder contents not same contents of c:\users\public\documents .

  • using cmd.exe lets me cd between folders expected, including c:\users\public\documents .

my environment
running microsoft visual studio community 2015 version 14.0.23107.0 d14rel, using microsoft visual c# 2015. operating system windows 10 pro.

if using system.windows.forms.openfiledialog can set:

dialog.autoupgradeenabled = false; 

the dialog little dated/flat/"old school" @ least display correct contents!


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -