View Full Version : Path Validation

10-08-2003, 11:17 AM
I can't believe this one hasn't been solved... so I am hoping that there is a quick answer to it.

Using the SdAskDestPath standard dialog, the user can browse to change the path. He can edit the path in a text box. It is possible to have the SdAskDestPath dialog return an invalid path.

start with C:\Program Files\YourCompany\YourProdcut
the user modifies this to C:YourCompany\YourProduct

It conforms to the checks (no illegal characters), but it's not a good path to try and install a program into!

I tried using ParsePath using the DISK and PATH operations, but they too accept this as a valid path.

Is there something simple I can do to confirm that the path entered is valid, or do I have to go to extreme lengths to check that there is a drive designation followed by a backslash followed by a folder etc. (Yes, it could be installing to a UNC, so start with \\machinename\sharename)

SdAskDestPath should be doing all this for me already, but no.

Please someone tell me how this can be achieved simply and elegantly.......


10-12-2003, 02:00 PM

Is(VALID_PATH, strPath)

do what you need?

10-13-2003, 04:58 AM
Sadly Is(VALID_PATH, strPath) does not help.

Nor does ParsePath(sPathOut, sPathIn, PATH).

My problem is that users can accidentally enter paths like

C:Program Files\company_name\

Which is considered to be a valid path.

I have had one user do exactly such a thing, and say that at the end of the install, the shortcuts created for him didn't work. When I have tried it, it did seem to work correctly, and the program was installed to C:\Program Files\...

This might well be a red-herring. I shall have to do further testing and see if this *is* a real problem!


01-13-2004, 07:39 PM
Yes, 'C:Program Files\company_name\' is a valid path, and can result in the effects reported. What it refers to is the folder 'Program Files\company_name\' in the default directory on C: drive. So if the default happens to be 'C:\SomeOtherDir' the install path will be 'C:\SomeOtherDir\Program Files\company_name\'

We get around this by looking for the root specification, like so
if ! (sPath % ":\\") then
deal with it...

If you want to allow UNC paths you'll have to add another condition

John Carver