Creates a new file or opens and truncates an existing file.
[ hFile = ] FileCreate ( sFileName [, lMode] )
The FileCreate procedure syntax has the following parts:
Name |
Type |
Description |
hFile |
Returned handle to file, -1 on error |
|
sFileName |
Val BString |
String containing the filename |
lMode |
Val enumAFileMode |
File mode |
enumAFileMode can be one or a combination of the following values, the combination of the default value constants are marked with an asterisk(*), which is:
aFileModeCreateAlways | aFileModeRead | aFileModeWrite | aFileModeShareRead | aFileModeShareWrite | aFileModeAttributeNormal
Name |
Value |
Description |
aFileModeRead |
0x00000001 * |
Allows Read access to the file |
aFileModeWrite |
0x00000002 * |
Allows Write access to the file |
aFileModeShareDelete |
0x00000010 |
File Share Delete. Subsequent open operation will succeed only if delete access is requested. |
aFileModeShareRead |
0x00000020 * |
File Share Read. Subsequent open operation will succeed only if read access is requested. |
aFileModeShareWrite |
0x00000040 * |
File Share Write. Subsequent open operation will succeed only if write access is requested. |
aFileModeCreateNew |
0x00000100 |
Creates a new file. This function fails if the specified file exists. |
aFileModeCreateAlways |
0x00000200 * |
Creates a new file. If the file exists, the function overwrites the file and clears the existing attributes. |
aFileModeOpenExisting |
0x00000400 |
Opens the file. The function fails if the file does not exist. |
aFileModeOpenAlways |
0x00000800 |
Opens the file if it exists. If the file does not exist, the function creates the file. |
aFileModeTruncateExisting |
0x00001000 |
Opens the file. Once opened, the file is truncated to 0 bytes. |
aFileModeAttributeArchive |
0x00010000 |
The file should be archived. It will be marked for backup or removal. |
aFileModeAttributeEncrypted |
0x00020000 |
All data in the file is encrypted. |
aFileModeAttributeHidden |
0x00040000 |
The file is hidden. |
aFileModeAttributeNormal |
0x00080000 * |
The file has no other attributes set. |
aFileModeAttributeOffline |
0x00100000 |
The file data has been physically moved to offline storage and is not immediately available. |
aFileModeAttributeReadOnly |
0x00200000 |
The file is set for read only. |
aFileModeAttributeSystem |
0x00400000 |
The file is part of or is used exclusively by the operating system. |
aFileModeAttributeTemporary |
0x00800000 |
The file is being used for temporary storage. |
aFileModeFlagWriteThrough |
0x02000000 |
Instructs the system to write through any intermediate cache and go directly to disk. The system can still cache write operations, but cannot flush them. |
aFileModeFlagNoBuffering |
0x04000000 |
Instructs the system to open the file with no intermediate buffering or caching. |
aFileModeFlagDeleteOnClose |
0x08000000 |
Indicates that the operating system is to delete the file immediately after all of its handles have been closed. |
If the file specified by sFileName does not exist, a new file is created. If the file already exists, the function truncates the file to length 0, destroying the previous contents.
The file is opened for read and write and then the file pointer is set to the beginning of the file.
One of the following Create/Open mode flags must be set for the function to be successful: aFileModeCreateNew, aFileModeCreateAlways, aFileModeOpenExisting, aFileModeOpenAlways, or aFileModeTruncateExisting.
If the function was successful, it returns the ATEasy file handle. Otherwise, it returns -1. Common causes for errors are: the given path or filename was not valid, the file is a read-only file, or there were too many open files.
hFile = FileCreate("\\~~a.txt")
If hFile = -1 Then
TestStatus=FAIL
Endif
FileClose, FileOpen, FileRemove, FileRename, FileSeek, FileTell, FileWrite, GetDir