Hi,

I've come across an issue where .Files.Count doesn't appear to be returning an accurate value. I can't seem to find an alternative nor why it wouldn't return the correct value - in the vast majority of cases it does.

I use the following code in a function to count the number of files in the location specified by the user. I then use the FileCount +1 for the upperbound limit of an array - this array is populated with details about each file.

Please Login or Register  to view this content.
For the majority of users' locations this is fine, but for two or three they are getting a Subscript out of Range error because the next file to add to the array is over the number of files expected.

I'm going to rework the array to populate the data in chunks and set a much larger upperbound limit (1048576), but this feel like a bit of a bodge rather than an actual solution.

Anyone else had any experience of this or have any alternative ways to count files - must be all files including system generated, shortcuts, temporary, hidden files, etc.

Thanks, TC