I am writing a web service that transfers a file over tcp using a binary, streaming connection.
I have some testing code set up but when I try to read the same file twice I get an exception, that the file is already open (by the previous call).
How can I close the file AFTER the transfer was complete? I tried a using block, but it didn’t work.
It’s covered here: http://devdump.wordpress.com/2008/12/07/disposing-return-values/
Furthermore, you probably want to open the streams using a constructor like this one, as follows:
That way, multiple clients can call your method simultaneously.