Question

For the .NET Micro Framework, is there a way to enumerate the files in a directory without loading the entire collection into memory?

Careful examination of the documentation says "No". For the full framework there is EnumerateFiles(path, pattern) which is similar to GetFiles except you get a lazy load collection instead of a string[]

How's that for irony? On tiny systems they expect you to load it all into RAM. NETMF42 doesn't look like getting EnumerateFiles either. Ideally, what we need is an overload for GetFiles taking two additional parameters, start and length, so that you can process bite sized chunks, which are bigger than byte-sized chunks but not big enough to cause memory exceptions (I'm sorry I couldn't resist it).

Était-ce utile?

La solution

Microsoft responded to direct correspondence.

Directory.EnumerateFiles() will be available in NETMF4.2


Time passed and voilà, EnumerateFiles duly appeared in 4.2 - and it does solve the problem, too.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top