?? mfindfile.bas
字號:
'//該源碼下載自www.aspx1.com(aspx1.com)
Attribute VB_Name = "mFindFile"
'****************************************************************************
'人人為我,我為人人
'枕善居收藏整理
'發布日期:2007/03/15
'描 述:網頁搜索音樂播放器 Ver 1.1.0
'網 站:http://www.Mndsoft.com/ (VB6源碼博客)
'網 站:http://www.VbDnet.com/ (VB.NET源碼博客,主要基于.NET2005)
'e-mail :Mndsoft@163.com
'e-mail :Mndsoft@126.com
'OICQ :88382850
' 如果您有新的好的代碼別忘記給枕善居哦!
'****************************************************************************
Option Explicit
'文件處理模塊
'========================================================
' 獲取文件的文件名及后綴名,不包含路徑
Function GetFileFullName$(ByVal strFileName$)
Dim nPos&, nTmpStr$
nTmpStr$ = strFileName$
Do
nPos& = InStr(1, nTmpStr$, "\")
If nPos& = 0 Then Exit Do '未找到 \ 符號,則取消搜索
nTmpStr$ = Right(nTmpStr$, Len(nTmpStr) - nPos&)
Loop
GetFileFullName$ = nTmpStr$
End Function
'========================================================
'========================================================
' 獲取文件的文件名,不包含路徑及后綴名
Function GetFileName$(ByVal strFileName_WithOutDir$)
Dim nPos&, nPosPrev&, nTmpStr$
Dim strcut As String
nTmpStr$ = strFileName_WithOutDir$
On Error Resume Next
nPos& = 0
Do
nPos& = InStr(nPos& + 1, nTmpStr$, ".")
If nPos& = 0 Then Exit Do
nPosPrev& = nPos&
Loop
If nPosPrev& = 0 Then
GetFileName = strFileName_WithOutDir$
Else
If Left(strFileName_WithOutDir$, 4) = "http" Then
strcut = "/"
Else
strcut = "\"
End If
GetFileName$ = Mid(strFileName_WithOutDir$, InStrRev(strFileName_WithOutDir$, strcut) + 1, nPosPrev& - 1)
End If
End Function
'========================================================
'========================================================
' 獲取文件的后綴名
Function GetFileSuffix$(ByVal strFileName_WithOutDir$)
Dim nPos&, nPosPrev&, nTmpStr$
nTmpStr$ = strFileName_WithOutDir$
On Error Resume Next
nPos& = 0
Do
nPos& = InStr(nPos& + 1, nTmpStr$, ".")
If nPos& = 0 Then Exit Do
nPosPrev& = nPos&
Loop
GetFileSuffix$ = UCase(Right(strFileName_WithOutDir, _
Len(strFileName_WithOutDir) - nPosPrev&))
End Function
'========================================================
'========================================================
' 獲取文件的大小
Function GetFileLen$(ByVal strFileName$)
Dim nLen As Double
nLen = FileLen(strFileName$)
If nLen < 1024 Then
GetFileLen$ = CStr(nLen) & "字節"
Else
GetFileLen$ = Format((nLen / 1024), "Fixed") & "KB"
End If
End Function
'========================================================
'========================================================
' 查找單一目錄下的文件,將其查找到的文件的全路徑及
' 名稱添加到 ByRef colFiles 集合中。
Function FindFilesInSingleDir&(ByVal strDir$, _
ByVal strPattern$, _
ByRef colFiles As Collection)
Dim cFind As New cFindFile
Dim strFile$
If Right(strDir, 1) <> "\" Then _
strDir = strDir & "\"
strFile = cFind.Find(strDir & strPattern)
Do While Len(strFile)
If (cFind.FileAttributes And vbDirectory) = 0 Then
' 將含有目錄的文件名添加到集合中
colFiles.Add strDir & strFile
End If
strFile = cFind.FindNext
Loop
FindFilesInSingleDir& = colFiles.Count
Set cFind = Nothing
End Function
'========================================================
'========================================================
' 查找包含子目錄下的文件,將其查找到的文件的全路徑及
' 名稱添加到 ByRef colFiles 集合中。
Function FindAllFiles&(ByVal strSearchPath$, _
strPattern As String, _
Optional colFiles As Collection, _
Optional colDirs As Collection, _
Optional blnDirsOnly As Boolean, _
Optional blnBoth As Boolean)
Dim cFind As New cFindFile
Dim strFile$
Dim intDirsFound%
If Right(strSearchPath, 1) <> "\" Then _
strSearchPath = strSearchPath & "\"
strFile = cFind.Find(strSearchPath & strPattern)
Do While Len(strFile)
If cFind.FileAttributes And vbDirectory Then
If Left(strFile, 1) <> "." Then
If blnDirsOnly Or blnBoth Then
addSingle strSearchPath & strFile
End If
intDirsFound = intDirsFound + 1
intDirsFound = intDirsFound + FindAllFiles( _
strSearchPath & strFile & "\", strPattern, _
colFiles, colDirs, blnDirsOnly)
End If
strFile = cFind.FindNext()
Else
If Not blnDirsOnly Or blnBoth Then
' 將含有目錄的文件名添加到播放列表
addSingle strSearchPath & strFile
End If
strFile = cFind.FindNext()
End If
DoEvents
Loop
FindAllFiles = intDirsFound
Set cFind = Nothing
End Function
'========================================================
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -