Possible Duplicate:
Convert a Stream to a FileStream in C#
My question is regarding the cast of stream to FileStream …
Basically I need to do that to get the name of the file, because if I have just an object Stream it doesn’t have the Name property, when FileStream does …
So how to do it properly, how to cast Stream object to FileStream …?
Another problem is that this stream comes from webResponse.GetResponseStream() and if I cast it to FileStream I get it empty. Basically I could also use stream but i need to get the file name.
I’m using 3.5
Any ideas?
Use the
asoperator to perform the cast, if theStreamis not actually aFileStream,nullwill be returned instead of throwing an exception.