次のエージェントは、ストリームの最後までバイトのブロックを読み込んで処理します。
Sub Initialize
REM Set names of input and output files
Const DIRECTORY = "c:¥StreamFiles¥"
Const FILENAME = "domobj"
Const EXT = ".tlb"
Dim inPath As String, outPath As String
inPath = DIRECTORY & FILENAME & EXT
outPath = DIRECTORY & FILENAME & "copy" & EXT
Dim session As NotesSession
Dim inStream As NotesStream, outStream As NotesStream
Set session = New NotesSession
REM Get the input file
Set inStream = session.CreateStream
If Not inStream.Open(inPath, "binary") Then
Messagebox inPath,, "Open failed"
Exit Sub
End If
If inStream.Bytes = 0 Then
Messagebox inPath,, "File has no content"
Exit Sub
End If
REM Get the output file
Set outStream = session.CreateStream
If Not outStream.Open(outPath, "binary") Then
Messagebox outPath,, "Open failed"
Exit Sub
End If
If outStream.Bytes <> 0 Then
Messagebox outPath,, "File exists and has content"
Exit Sub
End If
REM Transfer input file to output file
Do
buffer = inStream.Read(32767)
Call outStream.Write(buffer)
Loop Until inStream.IsEOS
Call inStream.Close
Call outStream.Close
End Sub