There is probably an API to do it, but here is some code I whipped up (VB6 only for JOIN/SPLIT functions):
Code:
Dim str As String
Dim strNew As String
Dim tmpArray() As String
Dim i As Integer
str = "C:\Program Files\Common Files\System"
tmpArray = Split(str, "\")
For i = LBound(tmpArray) To UBound(tmpArray)
If Len(tmpArray(i)) > 8 Then
tmpArray(i) = Left(tmpArray(i), 6) & "~1"
End If
Next i
strNew = Join(tmpArray, "\")
MsgBox strNew
This would not be reliable if there were two similar directory names, in DOS one would be ~1, the next would be ~2, etc. but the chance of that is usually pretty slim....
Tom