FileStream class leaks handles??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Has anyone seen a case where the FileStream class leaks handles? I have a program that runs in a loop and processes files in directories by reading them with a FileStream. Task manager shows that as the program runs the handle count rises and rises -- unless I comment out code that uses a FileStream. If I comment out the FileStream code the handle count stays fairly constant. Any ideas - I don't see anything in the knowledge base...

--Richard
 
Richard said:
Hi,

Has anyone seen a case where the FileStream class leaks handles? I have a program that runs in a loop and processes files in directories by reading them with a FileStream. Task manager shows that as the program runs the handle count rises and rises -- unless I comment out code that uses a FileStream. If I comment out the FileStream code the handle count stays fairly constant. Any ideas - I don't see anything in the knowledge base...

FileStream is a disposable class - do you call FileStream.Close()?

Better yet, use the 'using' statement to ensure that your FileStreams
are properly disposed.
 
Back
Top