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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Scott LysleRank #49 · 31K reputationPosted Nov 26, 2007, 9:27 PM EST
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());Patrick Lee3 reputationPosted Nov 27, 2007, 4:48 PM EST
Thank you that worked great!
Dim di = New DirectoryInfo("J:\Special\LQData")
Dim fi = di.GetFiles("*", SearchOption.AllDirectories)
MessageBox.Show(fi.Length.ToString)
~Patrick