- ©«¤l
- 109
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 114
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7 Win10
- ³nÅ骩¥»
- Office 2019 WPS
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ²`¦`
- µù¥U®É¶¡
- 2013-2-2
- ³Ì«áµn¿ý
- 2024-11-6
|
¦^´_ Joforn
³oVBA°õ¦æOK¡A¥i¬O¤¤¤åÀɮצWºÙ¦^¶ÇÅܦ¨¶Ã½X¡A½Ð°Ý³on¦p¦ó×¥¿¡A·P®¦
²Ä¤@ÓVBA°õ¦æ ...
ML089 µoªí©ó 2020-11-11 14:17 
.Pathªð¦^ªº¦}¤£¬O¶Ã½X¡A¦Ó¬O±N¤å¦r¶i¦æ¤FUrl½s½X¡A¥i¥H³q¹LUrl¸Ñ½X±o¨ìì¦r²Å¦ê¡A¤]¥i¥H¥Î¤U±ªº¤è¦¡ª½±µªð¦^¤å¦r®æ¦¡¡C- Public Property Get FTPSearch(ByVal FTPUrl As String, _
- Optional ByVal UserName As String, _
- Optional ByVal PassWord As String, _
- Optional ByVal Port As Integer) As Collection
-
- Dim objShell As Object, objFolder As Object
-
- On Error Resume Next
-
- If Len(FTPUrl) Then
- If Len(UserName) Then FTPUrl = UserName & ":" & PassWord & "@" & FTPUrl
- If Port > 0 Then FTPUrl = FTPUrl & ":" & Port
- Set objShell = CreateObject("Shell.Application")
- Set objFolder = objShell.Namespace("FTP://" & FTPUrl)
- End If
- Set FTPSearch = New Collection
- If objFolder Is Nothing Then Exit Function
-
- With objFolder
- If .ParentFolder.Self.IsFolder Then
- If .ParentFolder.ParseName(.Self.Name) Is Nothing Then
- Debug.Print "Error:Invalid Path!"
- ElseIf objFolder.Self.IsBrowsable Then
- Debug.Print "Error:Invalid Parameter!"
- ElseIf objFolder.Self.IsFolder Then
- Debug.Print "Start search files in path..."
- With objFolder
- FTPSearchWithShell FTPSearch, .ParentFolder.ParseName(.Self.Name).GetFolder
- End With
- Debug.Print "Files search completed."
- End If
- ElseIf objFolder.Self.IsFolder Then
- Debug.Print "Start search files in path..."
- With objFolder
- FTPSearchWithShell FTPSearch, objFolder
- End With
- Debug.Print "Files search completed."
- End If
- End With
- End Property
- Private Sub FTPSearchWithShell(ByVal Searched As Collection, ByVal Folder As Object, Optional ByVal strPath As String)
- Dim FolderItem As Object
- Dim objFolder As Object
- Dim subSearch As New Collection
-
- On Error Resume Next
-
- If Len(strPath) = 0 Then
- Set objFolder = Folder
- Do While (objFolder.ParentFolder.Self.IsFolder)
- strPath = objFolder.Self.Name & "/" & strPath
- Set objFolder = objFolder.ParentFolder
- Loop
- strPath = objFolder.Self.Path & strPath
- End If
-
- If Folder.Items.Count > 0 Then
- Set subSearch = New Collection
- For Each FolderItem In Folder.Items
- With FolderItem
- If .IsFolder Then
- Set Folder = .GetFolder
- If Folder.Items.Count Then subSearch.Add Folder
- ElseIf .IsBrowsable Then
- Searched.Add strPath & .Name
- End If
- End With
- Next FolderItem
-
- For Each Folder In subSearch
- FTPSearchWithShell Searched, Folder
- DoEvents
- Next Folder
- End If
- End Sub
- Sub Test()
- Dim Files As Collection
- Dim I As Long
-
- Set Files = FTPSearch("118.163.50.55/firmware_software_version_files/", "xxxxx", "xxxx")
- For I = 1 To Files.Count
- Debug.Print Files.Item(I)
- Next I
- End Sub
½Æ»s¥N½X |
|