|
-
Oct 27th, 2006, 05:29 PM
#1
Thread Starter
Lively Member
[RESOLVED] Get number of files in C:\
Hi guys, i want to know the total number of files in my C:\ partition, how can i do this?
Thx all
-
Oct 27th, 2006, 05:52 PM
#2
Re: Get number of files in C:\
VB Code:
Dim x as new System.IO.DirectoryInfo("C:\")
MessageBox.Show(x.GetFiles().Length.ToString())
-
Oct 27th, 2006, 06:10 PM
#3
Thread Starter
Lively Member
Re: Get number of files in C:\
Hi, First of all thx for reply but in this method i get only the number of files in C:\ directory, but i want to know all files contained in C:\ partition, the number in the subfolders too, can you help me?
-
Oct 27th, 2006, 06:14 PM
#4
Re: Get number of files in C:\
You would have to write a recursive function to do that and just keep returning the sum of the number of files. It should be pretty straightforward. Just use the same method there, but you have to use the GetDirectories function of the drive to get then iterate through each of the sub directories.
-
Oct 27th, 2006, 06:20 PM
#5
Thread Starter
Lively Member
Re: Get number of files in C:\
It sounds complex :P but i'll try, thx
-
Oct 27th, 2006, 07:01 PM
#6
Re: Get number of files in C:\
There's code for a recursive file search in the VB.NET Codebank forum. Note also that you may not have permission to open every folder so you would need to include exception handling for that situation and simply exclude those folders.
-
Oct 27th, 2006, 07:10 PM
#7
Thread Starter
Lively Member
Re: Get number of files in C:\
Yes, i use a try to log the files impossible to access, i try to search this code, Thx jmcilhinney
-
Oct 27th, 2006, 07:39 PM
#8
Thread Starter
Lively Member
Re: Get number of files in C:\
I love you :P i found it and it worked good, Thx a lot
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
|