How to save a NotesStream to a file?

I have a NotesStream loaded with binary data. Is there a way to save this into a file on hard drive? The binary data is actually a NSF. I don’t suppose the NotesStream can be converted to NotesDatabase object?

Subject: How to save a NotesStream to a file?

You need to use NotesStream.Open to associate a file with the stream BEFORE adding data to the stream, and no, you can’t convert the stream to a NotesDatabase object (although you can get the file as a NotesDatabase after it is written to disk).

Subject: RE: How to save a NotesStream to a file?

Thank you for the response. Stan. But, the problem is that there is no file at the first place. The byte array data is downloaded from a URL. NotesStream.Write to load the binary data into NotesStream. The question is how can I save this to a file?

Subject: RE: How to save a NotesStream to a file?

The file will be created on Open if it does not already exist. SO:

Set stream = session.CreateStream

Call stream.Open(“C:\Path\filename.ext”)

'Call your Write stuff here

Call stream.Close

Call stream.Truncate

At that point, the file is written to disk and the stream is cleared.