CreateFile()
Creates a binary file.
Syntax
CreateFile(<cFile>, <nAttribute>) --> lResult
Arguments
<cFile> is the name of the file to create, including the file extension. A drive letter and/or path name may also be included as part of the filename. If the file already exists it is destroyed and replaced with a new empty file of zero length.
<nAttribute> Is one of the following binary file attributes:
0 - normal read/write file. (This is the default setting if not specified.)
1 - create as read only.
2 - create a hidden file.
3 - create a system file.
Returns
Returns TRUE if the create file operation was successful, otherwise FALSE.
Description
This is a low level function that either creates a new file or opens and truncates an existing file. If <cFile> does not exist, it is created. If it does exist and can be opened for writing, it is truncated to zero-length.
After the file is created, data can be written to it or it can be closed. A created file should never be left open.
![]()
If you attempt to create a file and that file already exists, the contents of that file is destroyed!
CAPITAL Office only recognises files in the 8.3 file format. (8 characters maximum for the name plus up to three characters for the extension.) Do not attempt to rename a file to that of a long file name.
Once a file has been created it MUST be closed using the CloseFile() function.
Example
If CreateFile("C:\CAPITAL\mydata.dat")
WriteFile("C:\CAPITAL\mydaya.dat", "Hello World")
CloseFile("C:\CAPITAL\mydata.dat")
Endif
____________________________
Related Topics:
ReadFile()