L
Lee Crabtree
Is there some way to find out if a stream is already open? In
particular, I want to be able to switch from a NetworkStream to a
FileStream depending on input. I know I can use a Stream object and
cast it up, but how do I find out if the stream has been closed?
The pseudocode would go a little something like this:
public void OpenNetConnection(Socket connection)
{
if the stream is closed
open a new NetworkStream based on the connection Socket.
else
throw an exception
}
public void OpenFileConnection(string filename)
{
if the stream is closed
open a FileStream to the file
else
throw an exception
}
Lee Crabtree
particular, I want to be able to switch from a NetworkStream to a
FileStream depending on input. I know I can use a Stream object and
cast it up, but how do I find out if the stream has been closed?
The pseudocode would go a little something like this:
public void OpenNetConnection(Socket connection)
{
if the stream is closed
open a new NetworkStream based on the connection Socket.
else
throw an exception
}
public void OpenFileConnection(string filename)
{
if the stream is closed
open a FileStream to the file
else
throw an exception
}
Lee Crabtree