Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to make user input in textbox filename usable
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01194377
Message ID:
01194458
Views:
23
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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform