FileStream#
Qualified name: delphivcl.FileStream
- class FileStream#
Bases:
HandleStream
TFileStream enables applications to read from and write to a file on disk. Use TFileStream to access the information in disk files. TFileStream will open a named file and provide methods to read from or write to it. If an application already has a handle to the file, opened in the appropriate mode, use THandleStream instead.
Methods
Creates an instance of TFileStream.
Destroys an instance of TFileStream.
Frees the Wrapped Delphi Object
Returns True if Delphi Object is or inherits from ClassName
Read content as bytes.
Read content as float.
Read content as integer.
Read content as string.
Sets several properties in one call
If the object is a container (TStrings, TComponent...), it returns the content of the sequence as a Python list object.
If the object is a container (TStrings, TComponent...), it returns the content of the sequence as a Python tuple object.
Write content as bytes.
Write content as float.
Write content as integer.
Write content as string.
Attributes
Returns the TObject.ClassName
Preserves the file name of the file associated with the file stream.
Handle
Specifies the handle for the communications resource the stream reads from and writes to.
Position
Indicates the current offset into the stream for reading and writing.
Size
Indicates the size in bytes of the stream.
- ClassName#
Returns the TObject.ClassName
- Create(AFileName: string, Mode: Word)#
Creates an instance of TFileStream. Call Create to instantiate a file stream for reading from or writing to the named file. Specify the name of the file and the way the file should be opened as parameters. The Mode parameter indicates how the file is to be opened. The Mode parameter consists of an open mode and (possibly) a share mode or’ed together. The open mode must be one of the following values:
Value
Meaning
Declared In
fmCreate
Create a file with the given name. If a file with the given name exists, override the existing file and open it in write mode.
System.Classes
fmOpenRead
Open the file for reading only.
System.SysUtils
fmOpenWrite
Open the file for writing only. Writing to the file completely replaces the current contents.
System.SysUtils
fmOpenReadWrite
Open the file to modify the current contents rather than replace them.
System.SysUtils
The share mode must be one of the following values:
Value
Meaning
Declared In
fmShareCompat
Sharing is compatible with the way FCBs are opened.
System.SysUtils
fmShareExclusive
Other applications cannot open the file for any reason.
System.SysUtils
fmShareDenyWrite
Other applications can open the file for reading but not for writing.
System.SysUtils
fmShareDenyRead
Other applications can open the file for writing but not for reading.
System.SysUtils
fmShareDenyNone
No attempt is made to prevent other applications from reading from or writing to the file.
System.SysUtils
Note: On Windows, the Rights parameter is ignored. If the file cannot be opened, Create raises an exception. Creates an instance of TFileStream. Call Create to instantiate a file stream for reading from or writing to the named file. Specify the name of the file and the way the file should be opened as parameters. The Mode parameter indicates how the file is to be opened. The Mode parameter consists of an open mode and (possibly) a share mode or’ed together. The open mode must be one of the following values:
Value
Meaning
Declared In
fmCreate
Create a file with the given name. If a file with the given name exists, override the existing file and open it in write mode.
System.Classes
fmOpenRead
Open the file for reading only.
System.SysUtils
fmOpenWrite
Open the file for writing only. Writing to the file completely replaces the current contents.
System.SysUtils
fmOpenReadWrite
Open the file to modify the current contents rather than replace them.
System.SysUtils
The share mode must be one of the following values:
Value
Meaning
Declared In
fmShareCompat
Sharing is compatible with the way FCBs are opened.
System.SysUtils
fmShareExclusive
Other applications cannot open the file for any reason.
System.SysUtils
fmShareDenyWrite
Other applications can open the file for reading but not for writing.
System.SysUtils
fmShareDenyRead
Other applications can open the file for writing but not for reading.
System.SysUtils
fmShareDenyNone
No attempt is made to prevent other applications from reading from or writing to the file.
System.SysUtils
Note: On Windows, the Rights parameter is ignored. If the file cannot be opened, Create raises an exception.
- Destroy()#
Destroys an instance of TFileStream. Do not call Destroy directly in an application. Instead, call Free, which checks that the TFileStream reference is not nil and only then calls Destroy. Destroy closes the Handle for the file stream before freeing the object.
- FileName#
Preserves the file name of the file associated with the file stream. Use FileName to display the name of the file that TFileStream has accessed from disk. This is a read only property.
- Free()#
Frees the Wrapped Delphi Object
- InheritsFrom(ClassName)#
Returns True if Delphi Object is or inherits from ClassName
- ReadBytes()#
Read content as bytes.
- ReadFloat()#
Read content as float.
- ReadInt()#
Read content as integer.
- ReadString()#
Read content as string.
- SetProps(prop1=val1, prop2=val2...)#
Sets several properties in one call
- ToList()#
If the object is a container (TStrings, TComponent…), it returns the content of the sequence as a Python list object.
- ToTuple()#
If the object is a container (TStrings, TComponent…), it returns the content of the sequence as a Python tuple object.
- WriteBytes()#
Write content as bytes.
- WriteFloat()#
Write content as float.
- WriteInt()#
Write content as integer.
- WriteString()#
Write content as string.