File and Folder Functions

InstallShield 2024 » InstallScript Language Reference

File and folder functions provide a comprehensive way to work with text files, binary files, and folders. Many of the functions use the variables TARGETDIR (in InstallScript projects), INSTALLDIR (in InstallScript MSI and Basic MSI projects) and SRCDIR as the paths and accept only file names as parameters. Wild-card characters are also accepted where appropriate.

File and Folder Functions

Function

Description

ChangeDirectory

Makes the specified directory the current directory.

CloseFile

Closes an open file.

CopyFile

Copies a file from one folder to another.

CreateDir

Creates a new folder.

CreateFile

Creates a file with the specified file name.

DeleteDir

Deletes a folder.

DeleteFile

Deletes a file.

ExistsDir

Determines whether or not the specified directory exists.

ExistsDisk

Determines whether or not the specified disk exists.

FileCompare

Compares one file with another.

FileDeleteLine

Deletes a line in a text file.

FileGrep

Searches a text file for specified text.

FileInsertLine

Inserts a line in a text file.

FindAllDirs

Finds all subfolders under the specified folder.

FindAllFiles

Finds all files in the specified folder and its subfolders that match a file specification.

FindFile

Finds the first file in the specified folder that matches a file specification.

GetFileInfo

Retrieves a file's attributes, date, time, and size.

GetLine

Retrieves a line of text from an open file.

GetTempFileNameIS

Calls the Windows API GetTempFileName to create a temporary file and perform related actions. Note that unlike GetTempFileName, GetTempFileNameIS creates the folder specified by szPathName if it does not already exist.

Is

Provides file and path checking services, searches for a math coprocessor, tests for administrator privileges, determines whether a particular version of the .NET Framework or a language pack is present on the target system, determines whether Microsoft Windows is running from a shared copy on a network, and more.

OpenFile

Opens an existing file.

OpenFileMode

Sets the mode in which files will be opened with the OpenFile function.

ReadBytes

Reads the specified number of bytes from a binary file.

RenameFile

Renames a file.

SeekBytes

Positions the file pointer in a binary file.

SetFileInfo

Sets the attributes, date, and time of a file.

SetObjectPermissions

Sets permissions for a file, a folder, or a registry key. The file, folder, or registry key can be installed as part of your installation, or it can be already present on the target system.

WriteBytes

Writes a specified number of bytes to a binary file at the current file pointer location.

WriteLine

Writes a string to a text file.

XCopyFile

Copies one or more files from a source folder to a target folder, including subfolders if specified.

Related Function

Related Function

Function

Description

SelectDir

Presents a dialog that enables end users to select a folder. SelectDir creates the folder if it does not exist.