System.Classes.TFileStream.Create

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

constructor Create(const AFileName: string; Mode: Word); overload;
constructor Create(const AFileName: string; Mode: Word; Rights: Cardinal); overload;

C++

__fastcall TFileStream(const System::UnicodeString AFileName, System::Word Mode)/* overload */;
__fastcall TFileStream(const System::UnicodeString AFileName, System::Word Mode, unsigned Rights)/* overload */;

Properties

Type Visibility Source Unit Parent
constructor public
System.Classes.pas
System.Classes.hpp
System.Classes TFileStream

Description

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.

Exceptions

The constructor can raise an exception when it is unable to create or open a file. If it cannot create a file, it raises EFCreateError. If it cannot open a file, it raises EFOpenError.

See Also

Code Examples