首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎么修改这些代码使得一次把一个文件夹或者多个文件或文件夹同时拖入一个listbox后列出所有文件夹包含的文件或者所有一次性拖入的文件的

2012-01-14 
如何修改这些代码使得一次把一个文件夹或者多个文件或文件夹同时拖入一个listbox后列出所有文件夹包含的文

如何修改这些代码使得一次把一个文件夹或者多个文件或文件夹同时拖入一个listbox后列出所有文件夹包含的文件或者所有一次性拖入的文件的
Private   Sub   List1_OLEDragDrop(data   As   DataObject,   Effect   As   Long,   Button   As   Integer,   Shift   As   Integer,   x   As   Single,   y   As   Single)


List1.Clear
If   data.GetFormat(vbCFFiles)   Then   List1.AddItem   data.Files(1)


form_load事件中
List1.OLEDropMode   =   1

**********************************

以上代码可以拖动一个文件.多个文件就会自动选择一个文件

请问如果拖入一个或多个文件夹或者多个文件时

如何能够全部列出文件夹中的文件或者是所有多个文件

谢谢.

[解决办法]
找个遍历文件夹的例子参考
[解决办法]
偶要
ALL GIVE ME
[解决办法]
Option Explicit
Dim isPause As Boolean, isSearch As Boolean, isStop As Boolean
Private Sub Form_Load()
List1.OLEDropMode = 1
RestorePublic
End Sub

Private Sub List1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
List1.Clear
Dim t As Integer, ti As Integer
'On Error Resume Next
For t = 1 To Data.Files.Count
If Data.GetFormat(vbCFFiles) Then List1.AddItem Data.Files(t)
If GetAttr(Data.Files(t)) And vbDirectory Then
SeacherUserDir Data.Files(t), True
End If
Next t
End Sub

Private Sub SeacherUserDir(ByVal strPath As String, Optional ByVal isCheckSub As Boolean = True)
' '原作者:chenhui530 于 2007-3-17 21:55
Static sum As Long
Dim strFolders() As String, dirs As Integer, i As Integer
If Right(strPath, 1) <> "\ " Then strPath = strPath & "\ "
Dim strTmp As String
On Error Resume Next
strTmp = Dir(strPath & "*.* ", 1 Or 2 Or 4 Or vbDirectory)
Do While strTmp <> " "
sum = sum + 1
If sum Mod 20 = 0 Then DoEvents
If GetAttr(strPath & strTmp) And vbDirectory Then
If Left(strTmp, 1) <> ". " Then
Form1.List1.AddItem strPath & strTmp
'SendMessage Form1.List1.hWnd, WM_VSCROLL, SB_BOTTOM, 0&
ReDim Preserve strFolders(0 To dirs)
strFolders(dirs) = strPath & strTmp & "\ "
dirs = dirs + 1
End If
Else
Form1.List1.AddItem strPath & strTmp
'SendMessage Form1.List1.hWnd, WM_VSCROLL, SB_BOTTOM, 0&
End If
strTmp = Dir
Loop
If Not isCheckSub Then Exit Sub
For i = 0 To dirs - 1
If isStop Then isSearch = False: Exit For
SeacherUserDir strFolders(i), isCheckSub
Next
End Sub
Private Sub RestorePublic()
isStop = False
isPause = False
isSearch = False
End Sub


热点排行