Richard Blythe

Richard Blythe

  • NA
  • 101
  • 0

FileStream error. ????

Jul 6 2007 3:07 PM
I have written a class that stores user options throughout the program.  (Color preferences, startup windows, etc.)   When the program initializes,  a FileStream object is used to open then file then a binary formatter is used to deserialize the stream.  The FileStream is then closed.
The problem is that when the program closes and the FileStream object trys to open the file to save the updated user options.  A file exception is sometimes threw:  "Cannot access file because it is being used by another proccess".  Whats so annoying about the error is that it only happens SOMETIMES!  A debugging nightmare!  I assume that the object handle is not being released somewhere in memory.  Can anybody give me any pointers on overcoming this problem?

Answers (2)