TDosStream.Open

Open the file stream

Declaration

Source position: objects.pp line 353

default 
  procedure Open(OpenMode: Word);  Virtual;

Description

If the stream's status is stOK, and the stream is closed then Open re-opens the file stream with mode OpenMode. This call can be used after a Close call.

Errors

If an error occurs when re-opening the file, then Status is set to stOpenError, and the OS error code is stored in ErrorInfo

See also

Name Description
TDosStream.Close Close the file.
TStream.Open Open the stream

Example

Program ex14;
{ Program to demonstrate the TStream.Close method }
Uses Objects;
Var L : String;
    P : PString;
    S : PDosStream; { Only one with Close implemented. }
begin
  L:='Some constant string';
  S:=New(PDosStream,Init('test.dat',stcreate));
  Writeln ('Writing "',L,'" to stream with handle ',S^.Handle);
  S^.WriteStr(@L);
  S^.Close;
  Writeln ('Closed stream. File handle is ',S^.Handle);
  S^.Open (stOpenRead);
  P:=S^.ReadStr;
  L:=P^;
  DisposeStr(P);
  Writeln ('Read "',L,'" from stream with handle ',S^.Handle);
  S^.Close;
  Dispose (S,Done);
end.