说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

VB取得长文件名

HTML文档下载 WORD文档下载 PDF文档下载
VB取得长文件名
Public Function GetLongFilename (ByVal sShortName As String) As String

Dim sLongName As String
Dim sTemp As String
Dim iSlashPos As Integer

'Add \ to short name to prevent Instr from failing
sShortName = sShortName & "\"

'Start from 4 to ignore the "[Drive Letter]:\" characters
iSlashPos = InStr(4, sShortName, "\")

'Pull out each string between \ character for conversion
While iSlashPos
sTemp = Dir(Left$(sShortName, iSlashPos - 1), _
vbNormal + vbHidden + vbSystem + vbDirectory)
If sTemp = "" Then
'Error 52 - Bad File Name or Number
GetLongFilename = ""
Exit Function
End If
sLongName = sLongName & "\" & sTemp
iSlashPos = InStr(iSlashPos + 1, sShortName, "\")
Wend

'Prefix with the drive letter
GetLongFilename = Left$(sShortName, 2) & sLongName

End Function

备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘