Hello, I tested the cause of the phenomenon
Because the file name contains: ChrW(-29731)
In Chinese characters, it is:话
For example, the file name I tested was 神话.txt
The reason for the mistake seems to have come from: Path.cls Path.HasIllegalCharacters
Select Case PathChars(i)
Case vbQuoteChar, vbLessThanChar, vbGreaterThanChar, vbPipeChar, Is < vbSpaceChar
...
case Is < vbSpaceChar
< 32 ?
-29731 < 32
Error
but -29731 < 0
Not 0<xxx<32
Hope to be more compatible with Unicode characters, looking forward to your solution
Private Function HasIllegalCharacters(ByRef Path As String) As Boolean
Dim PathChars() As Integer
Dim i As Long
PathChars = AllocChars(Path)
For i = 0 To Len(Path) - 1
Select Case PathChars(i)
Case vbQuoteChar, vbLessThanChar, vbGreaterThanChar, vbPipeChar, Is < vbSpaceChar
MsgBox "HasIllegalCharacters:Error:" & i & "|" & PathChars(i)
HasIllegalCharacters = True
Exit For
End Select
Next
FreeChars PathChars
End Function
`--------------------------- Project1 Run-time error '5':
Invalid characters in path. OK
Hello, I tested the cause of the phenomenon Because the file name contains: ChrW(-29731) In Chinese characters, it is:话 For example, the file name I tested was 神话.txt
The reason for the mistake seems to have come from: Path.cls Path.HasIllegalCharacters Select Case PathChars(i) Case vbQuoteChar, vbLessThanChar, vbGreaterThanChar, vbPipeChar, Is < vbSpaceChar ...
case Is < vbSpaceChar < 32 ?
-29731 < 32 Error but -29731 < 0 Not 0<xxx<32
Hope to be more compatible with Unicode characters, looking forward to your solution
Private Function HasIllegalCharacters(ByRef Path As String) As Boolean Dim PathChars() As Integer Dim i As Long
PathChars = AllocChars(Path)
For i = 0 To Len(Path) - 1 Select Case PathChars(i) Case vbQuoteChar, vbLessThanChar, vbGreaterThanChar, vbPipeChar, Is < vbSpaceChar MsgBox "HasIllegalCharacters:Error:" & i & "|" & PathChars(i) HasIllegalCharacters = True Exit For End Select Next
FreeChars PathChars End Function
Originally posted by @wq1282 in https://github.com/kellyethridge/VBCorLib/issues/52#issuecomment-692592502