i.e.,
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 limitation
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.
Sunny SharmaPosted Jul 1, 2013, 5:53 AM
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 :)
nishant ranjanPosted Jul 1, 2013, 6:48 AM
nishant ranjanPosted Jul 1, 2013, 5:11 AM
DirectoryInfo di = new DirectoryInfo(@"D:\\");
Sunny SharmaPosted Jul 1, 2013, 4:58 AM
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!