Path: GetInvalidFileNameChars

GetInvalidFileNameChars

Gets an array containing the characters that are not allowed in file names.



 Public Function GetInvalidFileNameChars ( ) As Integer ( )

Return Values

Integer() -  An array containing the characters that are not allowed in file names.

Examples

The following code example demonstrates the GetInvalidFileNameChars method and the GetInvalidPathChars method to retrieve invalid characters.

Public Sub Main()
    Dim InvalidPathChars() As Integer
    Dim InvalidFileChars() As Integer
    
    InvalidPathChars = Path.GetInvalidPathChars
    
    Debug.Print "The following characters are invalid in a path:"
    ShowChars InvalidPathChars
    Debug.Print
    
    InvalidFileChars = Path.GetInvalidFileNameChars
    
    Debug.Print "The following characters are invalid in a filename."
    ShowChars InvalidFileChars
End Sub

Private Sub ShowChars(ByRef Chars() As Integer)
    Dim Ch As Variant
    
    Debug.Print "Char Hex Value"
    
    For Each Ch In Chars
        If Char.IsWhiteSpace(Ch) Then
            Debug.Print CorString.Format(",   {0:X4}", Ch)
        Else
            Debug.Print CorString.Format("{0:$},   {0:X4}", Ch)
        End If
    Next
End Sub

' Note: Some characters may not be displayable.
'
' This example code produces the following output.
'
'    The following characters are invalid in a path:
'    Char Hex Value
'    ",   0022
'    <,   003C
'    >,   003E
'    |,   007C
'    ...
'
'    The following characters are invalid in a filename.
'    Char Hex Value
'    ",   0022
'    <,   003C
'    >,   003E
'    |,   007C
'    ...

See Also

Project CorLib Overview

Class Path Overview