TempFile

TempFile

Creates a file for temporary use

Syntax

      TempFile([<cDirectory>], [<cExtension>], [<nFileAttr>])
             --> <cFileName>

Arguments

<cDirectory> : The drive and directory where the temporary file is to be created. The default is the system/user temp directory.

<cExtension> : The file extension for the file. The default is no extension.

<nFileAttr> : A file attribute for the file.

Returns

<cFileName> : The name of the temporary file. If no file is created, the function returns a null string.

Description

If you only need a file for a short time and want to avoid conflicts with existing files, use TempFile() to create a file with a unique name. Names created by TempFile() use the system date and system time. You can hide the file, if you specify an attribute. Attributes are coded as follows:

         File Attribute Coding
         ------------------------------------------------------------------------
         Value   Symb. constants     Definition
         ------------------------------------------------------------------------
         0       FA_NORMAL
         1       FA_READONLY         READ ONLY
         2       FA_HIDDEN           HIDDEN (Hidden files)
         4       FA_SYSTEM           SYSTEM (System files)
         32      FA_ARCHIVE          ARCHIVE (Changed since last backup)
         ------------------------------------------------------------------------

Notes

. The temporary file name is always 8 characters long and consists exclusively of numbers with a period, if no extension has been specified. The file is created with a length of 0 bytes.

Examples

      .  Create a temporary file in the system/user temp  directory:

         cTempFile := TempFile()

      .  Create a temporary file in the root directory of the E: drive:

         cTempFile := TempFile("E:\")

      .  Create a temporary file with a .TMP extension and a HIDDEN
         attribute in the root directory of the C: drive:

         cTempFile := TempFile("C:\", "TMP", 2)

Seealso

HB_FTempCreate(), HB_FTempCreateEx(), FCreate(), FErase(), FWrite(), HB_GetEnv()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.