I have a WCF service which is returning PDF files as a stream over a NetTcp endpoint. This is all working fine. However, if the file is not found, or if I can't find the related row in the database to retrieve the filepath then I return Stream.Null
from the service.
However I can't seem to find a way to compare the returning stream to check and see if it is empty or not.
I have tried the following:
If myStream IsNot Stream.Null
'Code to execute if stream isn't empty
End If
and
If Not streamPDF.Equals(Stream.Null)
'Code to execute if stream isn't empty
End If
But neither of these work as the code just carries on into the If
block.
Any thoughts?