Bad file name or number error in VB.Net
I have a form with two objects. One is of type MessageStore and the other NetListener, these are custom classes. NetListener listens for incoming messages from the network (this works fine). The MessageStore class works with a disk file opened using FileOpen.
What I want to do is when a new message arrives, to store it in the MessageStore. My code works as follows.
1. When a message arrives, my NetListener object raises an event, which is handled by a Sub in the main form.
2. From this event handler, when I try MessageStore.AddMessage(Msg) I get a "Bad file name or number" error in the AddMessage sub in the MessageStore class. The file number is 1 (same as when the file was opened and read from - file was not closed) but I get this error.
Calling MessageStore.AddMessage outside this even handler works without any error.
Any ideas as to why this does not work?
VB.Net 2005 (.Net 2.0)