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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top