|
|
Encode the contents of the specified file.
Syntax
object.EncodeFile( InputFile,
OutputFile, Encoding )
Remarks
The EncodeFile method encodes the contents of a file,
using the specified encoding method. The following parameters
should be passed as arguments to the method:
- InputFile
- The name of the file that is to be encoded. The file must
exist, and it must be a regular file that can be opened for reading
by the current process. An error will be returned if a character
device, such as CON: is specified as the file name.
- OutputFile
- The name of the file that is to contain the encoded file data.
If the file exists, it must be a regular file that can be opened
for writing by the current process and will be overwritten. If the
file does not exist, it will be created. An error will be returned
if a character device, such as CON: is specified as the file
name.
- Encoding
- The encoding method to be used when creating the file. The
following encoding methods are valid:
| Value |
Constant |
Description |
| 0 |
fileEncodeDefault |
Use the default encoding method. Currently this
is the same specifying that the base64 algorithm should be used for
encoding and decoding files. |
| 1 |
fileEncodeBase64 |
Use the base64 algorithm for encoding and
decoding files. This is the standard method for encoding files as
outlined in the Multipurpose Internet Mail Extensions (MIME)
protocol. This is the method used by most modern e-mail client
software. |
| 2 |
fileEncodeQuoted |
This encoding method is typically used for text
messages that use characters beyond the standard ASCII character
set, in the range of 128-255. This method, called quoted printable
encoding, allows text messages to pass through mail systems that do
not support characters with the high-bit set. Note that this method
should not be used to encode binary files such as executables or
file archives. |
| 3 |
fileEncodeUucode |
Use the uuencode and uudecode algorithms for
encoding and decoding files. This is a common encoding method used
with UNIX systems and older e-mail client software. |
| 4 |
fileEncodeYencode |
Use the yEnc algorithm for encoding the file.
This is an encoding method that is commonly used when posting files
to Usenet newsgroups. |
| &H10000 |
fileEncodeCompressed |
This option is used in combination with one of
the encoding types listed above. If specified, the file will be
compressed prior to being encoded by the control. This can
significantly reduce the size of the encoded output. |
Note that it is permitted to specify an empty string as the
output file name. In this case, the control will create a temporary
file in the directory specified by the TEMP environment variable.
After the file has been compressed, the OutputFile property
will be set the name of the temporary file that has been created.
It is the responsibility of the application to delete this
temporary file after it is no longer needed.
When specifying the fileEncodeCompressed option, it is
important to remember that the compressed, encoded data can only be
restored to its original contents using the DecodeFile
method. This option should not be used when encoding a file to be
attached to an email message unless you provide the recipient with
a utility to decode the data.
The InputFile, OutputFile and Encoding
properties will be updated with the values specified to this
method.
Return Value
This method returns a value of zero if the file was successfully
compressed. A non-zero return value specifies an error code which
indicates the reason for the failure.
See Also
Encoding Property,
InputFile Property,
OutputFile Property,
DecodeFile Method
|
|