Hello,
I am trying to write a program that counts how many files (any format of file) are in a directory. Anyone have any ideas on how to do this?
Thanks
Hello,
I am trying to write a program that counts how many files (any format of file) are in a directory. Anyone have any ideas on how to do this?
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Patrick LeePosted Nov 27, 2007, 9:48 PM
Thank you that worked great!
Dim di = New DirectoryInfo("J:\Special\LQData")
Dim fi = di.GetFiles("*", SearchOption.AllDirectories)
MessageBox.Show(fi.Length.ToString)
~Patrick
Scott LyslePosted Nov 27, 2007, 2:27 AM
Patrick:
Using System.IO, you can use the following code to get file information on all of the files in the root and subdirectories for the folder specified.
DirectoryInfo di = new DirectoryInfo("C:\\Temp"); FileInfo[] fi = di.GetFiles("*", SearchOption.AllDirectories); MessageBox.Show(fi.Length.ToString());