Notesstream open

The following code:

Set stream=session.CreateStream()

USEF=tmp+“\test.txt”

isopen=stream.open(USEF,“UTF-8”)

should create a file if the file “test.txt” does not exist. However, about 3 out of 10 times, it will generate the error message “file not found”.

Subject: problem Solving

From Help DB - “Closing a stream with zero bytes deletes the associated file.”

You can not use Kill.

the same:

Call stream.Truncate()

Call stream.Close()

Subject: I’ve seen this when the file previously existed and was opened in a NotesStream

during the same session. Restarting Notes clears it up.

Subject: restarting notes

This is an agent that is running on a server, therefore, restarting Notes is not really an option.

Subject: Then let’s look at the other side of the equation.

I think there’s no problem, if your code deletes the file itself rather than having it deleted by some other process. So, relevant questions:Is it necessary to use the same filepath each time?

Might you try deleting the file with Kill before opening it? Or trapping the error and using Kill then, before you try it again?

Can you arrange to not delete the file in the outside process? E.g. when you’re done you could truncate it instead of deleting?

Trap the error, and create the file by some other means (Open statement perhaps), then try again.

Could you use your imagination to think of alternate workarounds?

Reference SPR # AGUD8AMPWD

Subject: never observed in Notes 6.5.x, 7.x

I can confirm this issue.

  • never observed in Notes 6.5.x, 7.x

  • never observed when writing another file ( with different filename/path)

Try this before open then stream:

Call stream.Open(USEF & “dummy”,“utf-8”)

Call stream.Close()

This workaround will fix the problem for me.