saveFileDialog

  • Thread starter Thread starter radloff
  • Start date Start date
R

radloff

Hi :-)

Im quite comfortable implementing the saveFileDialog in a Windows
Application, but I seriously cannot imagine how to do that with the Compact
Framework. How could I work my way around the DialogResult=OK or the
OpenFile method in order to save my file in a folder selected by the
end-user?

Thank you
 
The compact framework version of the savefiledialog actually follows the
desktop model fairly closely. The main limitation is that you cannot specify
the InitialDirectory property - this will always be My Documents, and the
user can only select My Documents or a sub-folder thereof
In the case of Storage Cards if you have an "ignore_my_docs" file present it
will list the contents and 1 level depth of folders on the card, if you have
a My Documents folder on the card it will list its contents and 1 level
depth sub-folders.
The ShowDialog method will return a DialogResult - if this is
DialogResult.Ok then the FileName will be a valid filename which you can use
to write your file. e.g.

If (MySFDialog.ShowDialog() = DialogResult.OK) Then
'code to write the file here
fs = New FileStream(MySFDialog.FileName, FileMode.Create)
'etc
End If

As you don't have the OpenFile method, you can create a FileStream object
passing in the FileName property of the dialog. Note that the above code
does not differentiate if the file already exists, you can use the
System.IO.File.Exists methods to check this in the case that you want to
append if the file exists.


Peter

--
Peter Foot
Windows Embedded MVP

In The Hand
http://www.inthehand.com
 
Back
Top