Examples: Bytes property (NotesStream - LotusScript®)

This example gets the total bytes of all the normal files in a directory by opening each file as a stream and getting the Byte property.

Sub Initialize
  Dim session As New NotesSession
  Dim stream As NotesStream
  Set stream = session.CreateStream
  files& = 0
  bytes& = 0
  directory$ = "C:\StreamFiles"
  Chdir directory$
  file$ = Dir$("*.*")
  While file$ <> ""
    If Not stream.Open(path$ & file$) Then
      Messagebox file$,, "Open failed"
      Exit Sub
    End If
    files& = files& + 1
    bytes& = bytes& + stream.Bytes
    Call stream.Close
    file$ = Dir$()
  Wend
  Messagebox "Number of files = " & files& & Chr(13) & _
  "Total bytes = " & bytes&,, "Normal files in " & directory$
End Sub