Tuesday, August 25, 2020

[VB][Example] vb validate filename

Function example :

Public Shared Function isFilenameValid(ByVal fileNameas String) as Boolean

    Dim c As Char = String.Empty

    For each c in Path.GetInvalidFileNameChars()

        If fileName.Contains(c) Then

            Return False

        End If

    Next

    Return True

End Function


Reference:

https://stackoverflow.com/questions/1014242/valid-filename-check-what-is-the-best-way

No comments :

Post a Comment