Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to check for valid filename
Message
De
11/08/1999 10:59:04
 
 
À
11/08/1999 09:03:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00252469
Message ID:
00252537
Vues:
16
>I don't recall of a function in VFP to check for the validity of filenames.
>But maybe I overlooked it.
>Anybody now how to check the validity of a given filename.
>This comes in handy especially when users are specifying the name for export files.
>For example when they had a filename containing a "*".

There's a function in FOXTOOLS to do this, but it only works with 8.3 form names.

One quick way to check is to try to create the file using low-level I/O.
Function LegalName
LPARAMETER cNameToCheck
IF FILE(FULLPATH(cNameToCheck))
  *  it already exists, so its legal
  RETURN .t.
ELSE
  LOCAL nFH
  nFH=FCREATE(FULLPATH(cNameToCheck))
  IF nFH = -1
     *  Invalid, or can't create in any case
     RETURN .F.
  ELSE
     =FCLOSE(nFH)
     ERASE (FULLPATH(cNameToCheck)
     RETURN .T.
  ENDIF
ENDIF
>Maybe a Win32 API call ?
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform