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 displaysthis pc > documents > visual studio 2015 > projects > simplegame > controller > bin > debug". clicking in textbox causes displayc:\users\owner\documents\visual studio 2015\projects\simplegame\controller\bin\debug. therefore assumeopenfiledialogsilently handles invalidinitialdirectorynot changing directories. in case, defaulting project's assembly's bin'sdebugfolder.when
dlg.initialdirectory"c:\\"or"c:\\users\\"or"c:\\users\\public\\"dialog behaves expected. clicking in top textbox producesc:\orc:\usersorc:\users\publicrespectively.when
dlg.initialdirectory = "c:\\users\\public\\documents\\"dialog behaves incorrectly. top textbox shows> pc > documents, bottom textbox showsworld.txt. if click in top textbox, showsdocuments. displayed folder contents not same contents ofc:\users\public\documents.using
cmd.exelets mecdbetween folders expected, includingc:\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
Post a Comment