Notifications
Clear all
[Closed] test string for valid maxfile save
Mar 02, 2008 11:47 pm
Is there a way to test if a string is valid to be used to save a maxfile? As in path and filename in one string.
Cheers.
1 Reply
Mar 02, 2008 11:47 pm
Depending on exactly what you want, there are a number of different things you can do
fn isValidFilename sFilename = (
local bIsValid = true
local lstInvalid = #("<", ">", "|", "\"", "\\", "/", ":", "*", "?")
for sChar in lstInvalid do (
if (findString sFilename sChar) != undefined do (
bIsValid = false
break
)
)
return bIsValid
)
This function will determine if the “file” is valid (not if the path and extension) for windows long filenames.
If you have a full path, you will need to use “getFilenameFile” to extract just the “file” element of the string
You could use a string filter to determine if the directory structure existed or not as well, but it all depends on what it is you have and what you want to do with it
Shane