when using the .NET Directory class methods like EnumerateFiles or GetFiles or GetDirectories I assume that they take hold of an unmanaged handle. How is that handle released? are they using IDispose?
I mean is there possibility of a handle leak?
when using the .NET Directory class methods like EnumerateFiles or GetFiles or GetDirectories I
Share
No,
Directorydoesn’t implementIDisposable, and in fact all its methods are static. The releasing of the unmanaged handle must be within each method – if you really want to see more, try looking into it with something like Reflector.In fact, if you do this, you’ll find an internal class called
FileSystemEnumerableIterator<T>, which does implementIDisposableand whoseDisposemethod closes the handle.