|
-
May 1st, 2007, 02:25 AM
#1
Thread Starter
New Member
CD folder and file count
I want get count of files and folders exist in CD very fast, Like windows in my computer in propertise of each folder.
for sample "Cd contain : 25 Folders,120 Files"
-
May 1st, 2007, 02:40 AM
#2
Re: CD folder and file count
Code:
Option Explicit
Private Sub Dir1_Change()
File1.Path = Dir1.Path
Text1.Text = File1.ListCount
End Sub
Private Sub Form_Load()
On Error Resume Next
Drive1.Path = "D:"
End Sub
All you need is:
DirListBox called Dir1
FileListBox called File1
TextBox called Text1
and use that code It is simple and not the best way but it does work.
-
May 1st, 2007, 06:09 AM
#3
Thread Starter
New Member
Re: CD folder and file count
no.I want count of all subfolders and files
-
May 1st, 2007, 11:11 AM
#4
Re: CD folder and file count
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
May 1st, 2007, 11:29 AM
#5
Re: CD folder and file count
Code:
Option Explicit
Private Sub Form_Load()
Dim DirsCount As Long, FilesCount As Long
DirList "C:\", DirsCount, FilesCount
MsgBox FilesCount & " Files, " & DirsCount & " Folders"
End Sub
Private Sub DirList(ByVal Root As String, DirsCount As Long, FilesCount As Long)
Dim sDir As String
Dim Dirs As New Collection
If Right(Root, 1) <> "\" Then Root = Root & "\"
On Error Resume Next
sDir = Dir(Root & "*", vbArchive + vbDirectory + vbHidden + vbReadOnly + vbSystem)
Do Until Len(sDir) = 0
If sDir <> "." And sDir <> ".." Then
If (GetAttr(Root & sDir) And vbDirectory) = vbDirectory Then
If Err.Number = 0 Then
Dirs.Add sDir
DirsCount = DirsCount + 1
Else
FilesCount = FilesCount + 1
Err.Clear
End If
Else
FilesCount = FilesCount + 1
End If
End If
sDir = Dir
Loop
Do Until Dirs.Count = 0
DirList Root & Dirs(1), DirsCount, FilesCount
Dirs.Remove 1
Loop
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|