By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,131 Members | 1,494 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,131 IT Pros & Developers. It's quick & easy.

OpenFileDialog throws "Illegal characters in path"

P: n/a
Hi,

I have a OpenFileDialog on my windows form whose filter is *.*.
I want the users to be able to further filter the files by giving *.doc
or *.zip etc in the "file name" field of the dialog (Just like it
happens in the open file dialog of MS Word)
Currently, if the user enters a wild card character in the file name
field, it is throwing an exception with the message "Illegal characters
in path".
Please let me know how to achieve the above mentioned functionality.

Regards,
Shilpa

May 29 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try using.
MySaveFileDialogObject.Filter = "All Files(*.*)|*.*|Microsoft Office
Documnets (*.doc)|*.doc|Compressed Zipped Files(*.zip)|*.zip";

Obviously you can add or remove filters to the above string but the
format should be
{<Text to be displayed in the Save File Dialog>|<filter>}
Add a bar('|') to separate more than two filters.

I dont think you can specify the file name in the Save Dialog using
wild characters. The purpose of the Save Dialog is a valid File Name
and a valid File Location so that a file can be saved using this
location on the disk.

Hope that answers the question

May 29 '06 #2

P: n/a
Hi,

Thanks for the reply.
But my application requires the user to enter a wildcard character in
the file name of the OpenFileDialog (say *.zip) when the actual filter
of the dialog is *.*.
How do I go about doing this?

Regards,
Shilpa

May 30 '06 #3

P: n/a
Shilpa wrote:
But my application requires the user to enter a wildcard
character in the file name of the OpenFileDialog (say *.zip)
when the actual filter of the dialog is *.*.


If you set the ValidateNames property to false, then the FileDialog
will accept any non-empty string, even if it's not a legitimate
filename under Windows. You can then deal with it in your own code.

Eq.
May 30 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.