Using OpenFileDialog

When using the OpenFileDialog I am trying to open files in a directory based on the root. I have used the following code:

ofd1.InitialDirectory = "\"

ofd1.Filter = "all files|*.*|TextFiles|*.txt"

ofd1.FilterIndex = 1

If ofd1.ShowDialog = Windows.Forms.DialogResult.OKThen

TextBox2.Text = ofd1.FileName

EndIf

When the Dialog displays the Folder Dropdown shows 'All Folders' and a bunch of files, however, the dropdown only contains the folder names Contained in 'My Documents'.

My question is does anyone know a way to use the openfiledialog to Start at the root of the device so that even 'Storage Cards' can be accessed. What would really be nice if there was and UP that could be selected. All of the examples that I have found use

ofd1.InitialDirectory = "c:\"

which we all know is not Smart device compatable. I have considered doing it by hand using a combination of 'DirectoryInfo' and then doing the file/directory navigation by hand, but believe there is either a better way, or someone has done this in the past.

Thanks,

[1369 byte] By [BigBoom] at [2008-1-28]
# 1
It is a known limitation. If you create a My Documents directory on the Storage Card you should be able to browse that but for anything else you'll have to roll your own:
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework/search?hl=en&group=microsoft.public.dotnet.framework.compactframework&q=openfiledialog+%22my+documents%22&qt_g=1&searchnow=Search+this+group

Cheers
Daniel

DanielMoth at 2007-9-8 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2

This is the verified and documented behavior of the OpenFile dialog, so it is by design. On Devices, OpenFileDialog allows seeing only the My Documents directory and the directories that are contained within it. So the InitialDirectory property works as expected only if its value is set to a directory that is located inside of the My Documents directory otherwise its value is equal to "My Documents".

On the other hand, did you consider using the DocumentList Control that is a PPC only control. It is a lot more flexible and allows accessing the "Storage cards" as well. However this is a V2 only feature.

SrivaniVEluri at 2007-9-8 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 3
I am using VS2005 Beta 2 and tried the DocumentList Control. I tried setting the SelectedDirectory to "@","\","My Device" and still stuck with 'My Documents' stuff. It does appear however to list files based on the filter control that are on the storage card. Just can't go there directly.....
So back to roll-your-own....
Thanks anyway
BigBoom at 2007-9-8 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 4
Both the OpenFileDialog and DocumentList display consistent behaviour for the Pocket PC Platform. You can either place your files in a My Documents file on the storage card, or create a file called "ignore_my_docs" in the root of the SD card. This will make the dialogs pick up files from the root and one level deep.

Peter

PeterFoot at 2007-9-8 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...