Friday, April 25, 2014

Is Valid File Name? code from Microsoft :)

Function IsValidFileName (FileName)

    Dim regEx

    Set regEx = New RegExp
    regEx.Pattern = "[\x00-\x1F\<\>\:\""\/\\\|\%\*\?\']"   'Strict Subset
    IsValidFileName = (not regEx.Test ( FileName )) and (trim(FileName) <> "") and len(trim(FileName)) <= 253

    Select Case UCase(Trim(FileName))
    Case "CON", "AUX", "COM1", "COM2", "COM3", "COM4", "LPT1", "LPT2", "LPT3", "PRN", "NUL"
        IsValidFileName = FALSE
    End select

End function

No comments:

Post a Comment