vb6 – 如何只获取文件?
发布时间:2020-12-17 07:29:44 所属栏目:百科 来源:网络整理
导读:如何仅从文件的完整路径获取文件名? MY path - C:Documents and SettingsArshadMy Documentsravi.txt 解决方法 看看这个: Retrieve Filename without Path or Extension. 以下是上述链接的功能: Public Function GetFileName(flname As String) As St
如何仅从文件的完整路径获取文件名?
MY path - C:Documents and SettingsArshadMy Documentsravi.txt 解决方法
看看这个:
Retrieve Filename without Path or Extension.
以下是上述链接的功能: Public Function GetFileName(flname As String) As String 'Get the filename without the path or extension. 'Input Values: ' flname - path and filename of file. 'Return Value: ' GetFileName - name of file without the extension. Dim posn As Integer,i As Integer Dim fName As String posn = 0 'find the position of the last "" character in filename For i = 1 To Len(flname) If (Mid(flname,i,1) = "") Then posn = i Next i 'get filename without path fName = Right(flname,Len(flname) - posn) 'get filename without extension posn = InStr(fName,".") If posn <> 0 Then fName = Left(fName,posn - 1) End If GetFileName = fName End Function 输入时
这个函数返回
该函数被称为: Dim FileName As String FileName = GetFileName("C:Documents and SettingsArshadMy Documentsravi.txt") (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |