Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to make user input in textbox filename usable
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01194377
Message ID:
01194458
Vues:
25
This message has been marked as the solution to the initial question of the thread.
The following function will remove invalid characters from a file name (w/o path)
FUNCTION MakeFileNameValid(tcFileName)
* Removes invalid characters from a file name)
RETURN ALLTRIM(CHRTRAN(tcFileName, GetInvalidFileNameChars(), ""), " ", ".")

FUNCTION GetInvalidFileNameChars()
LOCAL lcInvalidFileNameChars, lnAsc
lcInvalidFileNameChars = ["*/:<>?\|]
FOR lnAsc=0 TO 31
	lcInvalidFileNameChars = lcInvalidFileNameChars + CHR(lnAsc)
ENDFOR
RETURN lcInvalidFileNameChars
Below are Windows limitation on file/path pulled from Windows SDK header file
* max. length of full pathname 
#define _MAX_PATH   260 
* max. length of path component 
#define _MAX_DIR    256 
* max. length of file name component
#define _MAX_FNAME  256 
* max. length of extension component
#define _MAX_EXT    256 
>
>I have a small program that gets 3 portions of a file path from comboboxes and the 4th is a textbox that is supposed to be the file name.
>
>How can I convert any invalid characters put in these portions to filename safe string. Plus what is the maximum length of a relative pathname ?
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform