Windows 10 allows to have paths > MAX_PATH (260 characters), but you'll have problems with VB and APIs.
Here is a workaround:
Prepending "\\?" to the path allows the GetShortPathNameW API to handle it and return a short path that the program can use.
PS: I passed the argument ByRef to make it work faster.
Here is a workaround:
Code:
Private Declare Function GetShortPathNameW Lib "kernel32" (ByVal lpszLongPath As Long, ByVal lpszShortPath As Long, ByVal cchBuffer As Long) As Long
Code:
Public Sub ShortenPath(nPath As String)
Const MAX_PATH = 260
Dim iRet As Long
Dim iBuff As String
If Len(nPath) > MAX_PATH Then
iRet = GetShortPathNameW(StrPtr("\\?\" & nPath), 0, 0)
If iRet Then
iBuff = Space$(iRet - 1)
If GetShortPathNameW(StrPtr("\\?\" & nPath), StrPtr(iBuff), iRet) Then
If Left$(iBuff, 4) = "\\?\" Then iBuff = Mid(iBuff, 5)
nPath = iBuff
End If
End If
End If
End Sub
PS: I passed the argument ByRef to make it work faster.