i.e.,
C#
FileInfo[] fiArr = di.GetFiles();
how much file info fiarr can hold, suppose we give c drive as get file to fiarr than how much file it will hold.
what is the limitation, and if exist how to overcome that limitation
FileInfo[] fiArr = di.GetFiles();
how much file info fiarr can hold, suppose we give c drive as get file to fiarr than how much file it will hold.
what is the limitation, and if exist how to overcome that limitationKnow 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 attend5days leftRegister
Sunny SharmaRank #223 · 11.1K reputationPosted Jul 1, 2013, 1:53 AM EDT
Of course, the answer remains same.
No matter how many files are there in any directory you point to. What only matters is how much free memory your system is occupied with.
For example, suppose you have a plastic bag having capacity of 10kg of rice. Now, if you will try to put packets of 1 kg-it can hold only 10. Likewise if you put packets of 100 grams it will hold a 100, and if you'll put packets of 10 grams it will hold a 1000 of packets.
Similarly, FileInfo[] or any Array can hold the maximum objects until the memory is out.
For your second question, I would say-You heard it right. Each File System can have specific naming rules about the formation of the individual components in the path to a directory or file. For NTFS they're limited to what you've heard i.e. Directory names cannot be longer than 248 characters and a filename (including it's path) cannot be longer than 260 characters. Refer to MSDN for more clarification.
So as long as you're using Windows, there's no way to overcome this naming limitation.
Hope it clarifies your question :)
Sunny SharmaRank #223 · 11.1K reputationPosted Jul 1, 2013, 12:58 AM EDT
Directory.GetFiles("some directory path"); gives you an array of strings which holds all the file names inside a directory. AFAIK, You cannot cast it to a FileInfo array. FileInfo object holds all the information pertaining to a single file hence FileInfo[] would expect an array of FileInfo objects not of the strings.
And, to answer your second part of question, the maximum length of any array is limited to the memory or virtual memory available.
Hope I answered your question.
Happy Coding :)
Cheers!
nishant ranjanRank #4,961 · 317 reputationPosted Jul 1, 2013, 1:11 AM EDT
DirectoryInfo di = new DirectoryInfo(@"D:\\");
FileInfo[] fiArr = di.GetFiles(); now i suppose fiArr will contain info of all file in d drive. let me know if am wrong.now suppose d\some folder contains million, billion of files than what is the limitation of fileinfo[]. is the answer remains same as u have posted??? plz explain the concept and one more query smwhere i read the file path which is stored in fileinfo length should not be greater than 260 char and directory name should not be greater than 248 char. is it true. if yes then there any way to overcome this limitationnishant ranjanRank #4,961 · 317 reputationPosted Jul 1, 2013, 2:48 AM EDT