PDA

View Full Version : Built-in function to check for valid file/folder name?



seaktf
10-29-2010, 04:53 AM
I'm asking this question to make sure I'm not reinventing the wheel.

In a dialog of my setup, users are asked to enter a string which will be used to create a subfolder's name later. Is there any built-in function to check if the string contains valid characters for folder name? You know, eg * > / are not allowed in a folder's name.

Well, I've looked through string functions and file/folder functions and can't find any. All I could make up so far is this:
Is(VALID_PATH, WINDISK ^ szDir)
where szDir contains the string to check.

Is there any case where this could fail to check the validity of folder name?

Kramer
10-29-2010, 09:39 AM
I do almost the exact same thing to specify (and create if necessary) a transfer folder on a project and it works fine. I also trap the CreateDir call for error conditions just in case though.

If you wanted to be really paranoid couldn't you do a series of 'StrReplace' calls for each invalid character to just remove them all? There arn't that many (http://support.microsoft.com/kb/909264).