步骤一
在Form中加入一个FileListBox,一个DirListBox,一个Label.
步骤二
在Form中加入以下代码:
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal
lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Private Sub Dir1_Change()
File1 = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1 = Drive1
End Sub
Private Sub File1_Click()
Label1.Caption = GetShortFileName(Dir1 & "\" & File1)
End Sub
Public Function GetShortFileName(ByVal FileName As String) As String
'converts a long file and path name to old DOS format
'PARAMETERS
' FileName = the path or filename to convert
'RETURNS
' String = the DOS compatible name for that particular FileName
Dim rc As Long
Dim ShortPath As String
Const PATH_LEN& = 164
'get the short filename
ShortPath = String$(PATH_LEN + 1, 0)
rc = GetShortPathName(FileName, ShortPath, PATH_LEN)
GetShortFileName = Left$(ShortPath, rc)
End Function
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073