object.Open ( FileName [,Mode] [,Format] )
- Required. A String that represents the full path of the file.
- Optional. A Long that represents the read/write mode of the file.
- Optional. A Long that represents the file format.
Mode is a long representing the read/write mode of the file. If not specified, Mode is apFileRead. [Optional]. The following Mode values are supported:
|apFileRead||Open a file for reading only. You cannot write to this file.|
|apFileWrite||Open a file for writing. If a file with the same name exists, its previous contents are overwritten.|
|apFileAppend||Open a file and write to the end of the file.|
Format is a long representing the format of the file. If not specified, Format is apFileASCII. [Optional]. The following Format values are supported:
|apFileASCII||Opens the file as ASCII.|
|apFileUnicode||Opens the file as Unicode.|
|apFileSystemDefault||Opens the file using the system default.|
ArcPad reads and writes files using the File object based on the format specified when the Open method is called. The format is applied as follows:
Format = apFileASCII. This mode is ideal for reading and writing 8-bit data. No translation or mapping is applied when using this format. Data is read and written as-is. If you attempt to call WriteLine to write characters that are based on a 16-bit character set, only the lower 8-bits of each character will be written. This format is ideal for read/writing binary data and the ReadByte/WriteByte, ReadShort/WriteShort, ReadLong/WriteLong, ReadFloat/WriteFloat and ReadDouble/WriteDouble methods.
Format = apFileUnicode. This mode is ideal for reading and writing 16-bit text data expressed using Unicode standards. This format is capable of reading 3 types of Unicode formats (Unicode, Unicode Big Endian, and Unicode UTF8). However, this mode can only create files in 2 of the 3 Unicode formats (Unicode and Unicode Big Endian). When reading a Unicode file, the text file's 2 byte/3 byte header is checked to automatically determine which type of Unicode it is. When writing a Unicode file, the BigEndian property is checked to determine whether to create a Unicode file (ideal for Microsoft Windows) or a Unicode Big Endian file (ideal for UNIX and Apple based systems). Note that BigEndian's default value is false. If you wish to create a Unicode UTF8 file, set the CodePage property to 65001 (UTF8) and call the Open method with Format of apFileSystemDefault.
Format = apFileSystemDefault. This mode is ideal for reading and writing textfiles that are not encoded in Unicode. The system format is used to represent 16-bit text using a multibyte 8-bit character set encoding. You need to set the CodePage property prior to calling the Open method in order to be able to read and write a text file localized for a foreign country. For example, Japanese Shift-JIS (932), Chinese Traditional in Big5 (950), Chinese Simplified (936), and Unicode UTF8 (65001). If you do not set the CodePage property, it will be initialized to a default based on your current Operating System's language.
Note that when setting Format = apFileSystemDefault some code pages may not be installed on your system. For example, Japanese Shift-JIS (932) may not be installed on an English version of Windows. You need to check/set the Region and Language Options in the Control Panel to ensure that foreign language locales are installed. When given the choice, it is best to use Unicode (including Unicode UTF8) to ensure that a text file manipulated via the File object is readable on all platforms.