Create a file or open and truncate an existing file, specifying two strongly typed arguments.
XSharp.Core (in XSharp.Core.dll) Version: 2.7
Syntax Request Example
cFileName AS STRING,
dwAttributes AS DWORD
) AS IntPtr
public static IntPtr FCreate2(
- 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.
- Type: UInt32
One of the following constants indicating the attribute to be set when creating the file:
FC_ARCHIVED Archived file
FC_HIDDEN Hidden file
FC_NORMAL Normal read/write file
FC_READONLY Read-only file
FC_SYSTEM System file
The DOS file handle number of the new file.
If an error occurs, FCreate2() returns F_ERROR. FError() can be used to determine the specific error.
The low level File IO functions in the X# runtime are using .Net filestreams in the background. |
That means that the file handles returned by FOpen() and FCreate() are not 'normal' file handles,
but unique identifiers that are used to find the underlying stream object in a collection of
streams in the runtime.
That also means that you can't use file handles for functions such as FRead() and FWrite() that were not
created in the X# runtime.
If you want to access the underlying FileStream, then you should call the
This example creates a file called TESTFILE.TXT and opens it for reading and writing:
1ptrHandle := FCreate2("testfile.txt", FC_NORMAL)
2IF ptrHandle = F_ERROR
3 ? DOSErrString(FError())
5 FWrite(ptrHandle, "Hello there")