Use File methods to manipulate Windows files, folders, and
paths in your automations.
Directory methods
Method | Description |
CopyDirectory | Copies the contents of a directory into another directory. You
can optionally overwrite the files in the directory. |
CreateDirectory | Creates all of the directories and subdirectories in the
specified path. The path parameter specifies a directory path,
not a file path. |
DeleteDirectory | Deletes a directory at the path you specify, including all of its
subdirectories and any files in those directories. |
DirectoryExists | Determines whether the specified directory exists. |
GetDirectoriesInDirectory | Returns the paths of the subdirectories in the directory that you
specify. |
MoveDirectory | Moves a file or a directory and its contents to a new
location. If you try to move a directory to a directory that
already exists, nothing is moved and the method returns
False. |
RenameDirectory | Renames the directory that you specify. |
File contents methods
Method | Description |
AppendAllLines | Appends lines to a file, and then closes the file. |
AppendAllText | Appends the specified string to the file. Creates the file if it
does not exist. |
AppendText | Creates a StreamWriter that appends UTF-8 encoded text to a file
or creates a new file with that text, if the specified file does not
exist. |
Decrypt | Decrypts a file that was encrypted by the current account using
the Encrypt(String) method. |
Encrypt | Encrypts a file so that only the account used to encrypt the file
can decrypt it. |
ReadAllBytes | Opens a binary file, reads the contents of the file into a byte
array, and then closes the file. |
ReadAllLines | Opens a text file, reads all lines of the file into a string
array, and then closes the file. |
ReadAllText | Opens a text file, reads all the text in the file into a string,
and then closes the file. |
ReadLines | Reads the lines of a file. |
WriteAllBytes | Creates a new file, writes the specified byte array to the file,
and then closes the file. If the target file already exists, it is
overwritten. |
WriteAllLines | Creates a new file, writes one or more strings to the file, and
then closes the file. |
WriteAllText | Creates a new file, write the contents to the file, and then
closes the file. If the target file already exists, the system
overwrites it. |
File management methods
Method | Description |
CopyFile | Copies an existing file to a new file. |
CreateFile | Creates a file, writes the specified byte array to the file, and
then closes the file. If the target file already exists, the system
overwrites it. |
DeleteFile | Deletes the specified file. |
FileExists | Determines whether the specified file exists. |
GetAttributes | Gets the FileAttributes of the specified file. |
GetFileInfo | Returns the creation date and last updated date for the specified
file. |
GetFiles | Returns the names and paths of the files that meet specified
criteria. |
GetFilesInDirectory | Returns the names and paths of the files that meet specified
criteria. |
GetFilesUnderDirectory | Determines if the specified file is in the specified
directory. |
MoveFile | Moves a specified file to a new location, and provides the option
to specify a new file name. |
ReplaceFile | Replaces the contents of a specified file with the contents of
another file. Creates a backup of the original file and then deletes
it. |
SetAttributes | Sets the specified FileAttributes of the file on the specified
path. |
TouchFile | Updates the LastWriteTime and LastAccessTime for the specified
file. |
Find methods
Method | Description |
FindInFiles | Returns a read-only collection of strings that represent the
names of the files that contain the specified text. |
Path methods
Method | Description |
CombinePaths | Combines strings into a path. |
GetDirectoryName | Returns the directory information for the specified path. |
GetFileExtension | Returns the extension, including the period, of the specified
path string. |
GetFileName | Returns the file name and extension of the specified path
string. |
GetFileNameWithoutExtension | Returns the file name of the specified path string without the
extension. |
GetFullPath | Returns the absolute path for the specified path string. |
GetParentDirectory | Returns the directory information for the specified path. |
Zip methods
Method | Description |
CreateZipFromDirectory | Creates a ZIP archive that contains the files and directories
from the specified directory. |
ExtractZipToDirectory | Extracts all the files in the specified ZIP archive to a
directory on the file system. |
Open | Opens a ZIP archive at the specified path and in the specified
mode. |
OpenRead | Opens a ZIP archive for reading at the specified path. |