获取路径名的原始大小写状态
方法1:
'利用dir()循环:
------------------------------------
Option Explicit
Private Sub Command1_Click()
Dim s As String
s = "c:/program files/microsoft office/office11/winword.exe"
MsgBox "lcase: " & s & vbCrLf & "inipath: " & inipath(s)
End Sub
Function inipath(ByVal lcasepath As String) As String
Dim x() As String, temp() As String, n As Integer, i As Integer
x = Split(lcasepath, "/")
n = UBound(x)
ReDim temp(n)
temp(0) = UCase(x(0))
For i = n To 1 Step -1
ReDim Preserve x(i)
temp(i) = Join(x, "/")
temp(i) = IIf(i = n, Dir(temp(i)), Dir(temp(i), vbDirectory))
Next
inipath = Join(temp, "/")
End Function
方法2:
''使用File System Object:
Private Sub Command1_Click()
Dim s As String
s = "c:/program files/microsoft office/office11/winword.exe"
Dim fso As New FileSystemObject
MsgBox fso.GetAbsolutePathName(s)
End Sub