Masking valid file names

T

~toki

I need to check if the user put some invalid char when he name a file to
save.
Exists any function that check this? (prevent / * ; etc)
 
S

Scatropolis

I didn't see it but there should be something in System.IO.Path.

Depending on what you need, the saveFileDialog has it built in (it won't let
an invalid filename be entered)
 
T

~toki

saveFileDialog
is a good idea, with a littles changes to my code i can use it.
thanks,
 
J

Justin Rogers

System.IO.Path, contains the InvalidPathChars property you can use within a
regular
expression to see if a Path is invaid, or you can call IndexOfAny on the path
and pass
in InvalidPathChars I believe.

Additionally, you can use the security system to ensure the user doesn't do
anything funny
by locking them down to specific directories or locations that they can write to
(this ensures
they can't write paths that recurse, etc...). You can view my blog entry on
this at:

http://weblogs.asp.net/justin_rogers/archive/2004/01/19/60435.aspx
or all of my security type posts (contains an enhancement on the original
article) at:
http://weblogs.asp.net/justin_rogers/category/3012.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top