Functions.FCreate Method (String)
Create a file or open and truncate an existing file.
XSharp.Core (in XSharp.Core.dll) Version: 2.16
Syntax Request Example
cFileName AS STRING
) AS IntPtr
public static IntPtr FCreate(
- Type: String
The name of the file to create, including an optional drive, directory, and extension. SetDefault() and SetPath() settings are ignored; the Windows default is used unless you specify a drive and directory as part of the file name. No extension is assumed.
If the file already exists, its length is truncated to 0 without warning.
This function sets NetErr() in case of a concurrency control conflict.
The DOS file handle number of the new file.
If an error occurs, FCreate() returns F_ERROR. FError() can be used to determine the specific error.
FCreate() is a low-level file function that either creates a new file or opens an existing file and truncates it to 0 length.
If cFileName does not exist, it is created and opened for writing.
If it does exist and can be opened for writing, it is truncated to 0 length.
When FCreate() successfully creates a new file, the file is left open in compatibility sharing mode and read/write access mode.
The file attribute specified by nAttribute is applied to the new file when it is closed, allowing you to write to a newly created read-only file.
For a list of access modes, see FOpen().
Since a file handle is required in order to identify an open file to other file functions, always assign the return value from FCreate() to a variable for later use.
This example creates a file called TESTFILE and opens it for reading and writing:
1IF (ptrHandle := FCreate("testfile")) = F_ERROR
2 ? DOSErrString(FError())
4 FWrite(ptrHandle, "Hello there")