File Management Functions

The following functions are used to manage files.

In this section

Function Description
AddUsersToEncryptedFile
Adds user keys to the specified encrypted file.
AreFileApisANSI
Determines whether the file I/O functions are using the ANSI or OEM character set code page.
CancelIo
Cancels all pending input and output (I/O) operations that are issued by the calling thread for the specified file.
CancelIoEx
Marks any outstanding I/O operations for the specified file handle. The function only cancels I/O operations in the current process, regardless of which thread created the I/O operation.
CancelSynchronousIo
Marks pending synchronous I/O operations that are issued by the specified thread as canceled.
CheckNameLegalDOS8Dot3
Determines whether the specified name can be used to create a file on a FAT file system.
CloseEncryptedFileRaw
Closes an encrypted file after a backup or restore operation, and frees associated system resources.
CopyFile
Copies an existing file to a new file.
CopyFile2
Copies an existing file to a new file, notifying the application of its progress through a callback function.
PCOPYFILE2_PROGRESS_ROUTINE
An application-defined callback function used with the CopyFile2 function.
CopyFileEx
Copies an existing file to a new file, notifying the application of its progress through a callback function.
CopyFileTransacted
Copies an existing file to a new file as a transacted operation, notifying the application of its progress through a callback function.
CopyProgressRoutine
An application-defined callback function used with the CopyFileEx, MoveFileTransacted, and MoveFileWithProgress functions.
CreateFile
Creates or opens a file or I/O device. The most commonly used I/O devices are as follows: file, file stream, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, and pipe.
CreateFile2
Creates or opens a file.
CreateFileTransacted
Creates or opens a file, file stream, or directory as a transacted operation.
CreateHardLink
Establishes a hard link between an existing file and a new file.
CreateHardLinkTransacted
Establishes a hard link between an existing file and a new file as a transacted operation.
CreateIoCompletionPort
Creates an input/output (I/O) completion port and associates it with a specified file handle, or creates an I/O completion port that is not yet associated with a file handle, allowing association at a later time.
CreateSymbolicLink
Creates a symbolic link.
CreateSymbolicLinkTransacted
Creates a symbolic link as a transacted operation.
DecryptFile
Decrypts an encrypted file or directory.
DeleteFile
Deletes an existing file.
DeleteFileTransacted
Deletes an existing file as a transacted operation.
DuplicateEncryptionInfoFile
Copies the EFS metadata from one file or directory to another.
EncryptFile
Encrypts a file or directory.
EncryptionDisable
Disables or enables encryption of the specified directory and the files in it.
ExportCallback
An application-defined callback function used with ReadEncryptedFileRaw.
FileEncryptionStatus
Retrieves the encryption status of the specified file.
FileIOCompletionRoutine
An application-defined callback function used with the ReadFileEx and WriteFileEx functions. It is called when the asynchronous input and output (I/O) operation is completed or canceled and the calling thread is in an alertable state.
FindClose
Closes a file search handle opened by the FindFirstFile, FindFirstFileEx, FindFirstFileNameW, FindFirstFileNameTransactedW, FindFirstFileTransacted, FindFirstStreamTransactedW, or FindFirstStreamW functions.
FindFirstFile
Searches a directory for a file or subdirectory with a name that matches a specific name (or partial name if wildcards are used).
FindFirstFileEx
Searches a directory for a file or subdirectory with a name and attributes that match those specified.
FindFirstFileNameTransactedW
Creates an enumeration of all the hard links to the specified file as a transacted operation. The function returns a handle to the enumeration that can be used on subsequent calls to the FindNextFileNameW function.
FindFirstFileNameW
Creates an enumeration of all the hard links to the specified file. The FindFirstFileNameW function returns a handle to the enumeration that can be used on subsequent calls to the FindNextFileNameW function.
FindFirstFileTransacted
Searches a directory for a file or subdirectory with a name that matches a specific name as a transacted operation.
FindFirstStreamTransactedW
Enumerates the first stream in the specified file or directory as a transacted operation.
FindFirstStreamW
Enumerates the first stream with a ::$DATA stream type in the specified file or directory.
FindNextFile
Continues a file search from a previous call to the FindFirstFile, FindFirstFileEx, or FindFirstFileTransacted functions.
FindNextFileNameW
Continues enumerating the hard links to a file using the handle returned by a successful call to the FindFirstFileNameW function.
FindNextStreamW
Continues a stream search started by a previous call to the FindFirstStreamW function.
FlushFileBuffers
Flushes the buffers of a specified file and causes all buffered data to be written to a file.
FreeEncryptionCertificateHashList
Frees a certificate hash list.
GetBinaryType
Determines whether a file is an executable (.exe) file, and if so, which subsystem runs the executable file.
GetCompressedFileSize
Retrieves the actual number of bytes of disk storage used to store a specified file.
GetCompressedFileSizeTransacted
Retrieves the actual number of bytes of disk storage used to store a specified file as a transacted operation.
GetExpandedName
Retrieves the original name of a compressed file, if the file was compressed by the Lempel-Ziv algorithm.
GetFileAttributes
Retrieves file system attributes for a specified file or directory.
GetFileAttributesEx
Retrieves attributes for a specified file or directory.
GetFileAttributesTransacted
Retrieves file system attributes for a specified file or directory as a transacted operation.
GetFileBandwidthReservation
Retrieves the bandwidth reservation properties of the volume on which the specified file resides.
GetFileInformationByHandle
Retrieves file information for the specified file.
GetFileInformationByHandleEx
Retrieves file information for the specified file.
GetFileSize
Retrieves the size of the specified file, in bytes.
GetFileSizeEx
Retrieves the size of the specified file.
GetFileType
Retrieves the file type of the specified file.
GetFinalPathNameByHandle
Retrieves the final path for the specified file.
GetFullPathName
Retrieves the full path and file name of the specified file.
GetFullPathNameTransacted
Retrieves the full path and file name of the specified file as a transacted operation.
GetLongPathName
Converts the specified path to its long form.
GetLongPathNameTransacted
Converts the specified path to its long form as a transacted operation.
GetQueuedCompletionStatus
Attempts to dequeue an I/O completion packet from the specified I/O completion port.
GetQueuedCompletionStatusEx
Retrieves multiple completion port entries simultaneously.
GetShortPathName
Retrieves the short path form of the specified path.
GetTempFileName
Creates a name for a temporary file. If a unique file name is generated, an empty file is created and the handle to it is released; otherwise, only a file name is generated.
GetTempPath
Retrieves the path of the directory designated for temporary files.
ImportCallback
An application-defined callback function used with WriteEncryptedFileRaw. The system calls ImportCallback one or more times, each time to retrieve a portion of a backup file's data.
LockFile
Locks the specified file for exclusive access by the calling process.
LockFileEx
Locks the specified file for exclusive access by the calling process. This function can operate either synchronously or asynchronously and can request either an exclusive or a shared lock.
LZClose
Closes a file that was opened by using the LZOpenFile function.
LZCopy
Copies a source file to a destination file.
LZInit
Allocates memory for the internal data structures required to decompress files, and then creates and initializes them.
LZOpenFile
Creates, opens, reopens, or deletes the specified file.
LZRead
Reads (at most) the specified number of bytes from a file and copies them into a buffer.
LZSeek
Moves a file pointer the specified number of bytes from a starting position.
MoveFile
Moves an existing file or a directory, including its children.
MoveFileEx
Moves an existing file or directory, including its children, with various move options.
MoveFileTransacted
Moves an existing file or a directory, including its children, as a transacted operation.
MoveFileWithProgress
Moves a file or directory, including its children. You can provide a callback function that receives progress notifications.
OpenEncryptedFileRaw
Opens an encrypted file in order to backup (export) or restore (import) the file.
OpenFile
Creates, opens, reopens, or deletes a file.
OpenFileById
Opens the file that matches the specified identifier.
PostQueuedCompletionStatus
Posts an I/O completion packet to an I/O completion port.
QueryRecoveryAgentsOnEncryptedFile
Retrieves a list of recovery agents for the specified file.
QueryUsersOnEncryptedFile
Retrieves a list of users for the specified file.
ReadEncryptedFileRaw
Backs up (export) encrypted files.
ReadFile
Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device.
ReadFileEx
Reads data from the specified file or input/output (I/O) device. It reports its completion status asynchronously, calling the specified completion routine when reading is completed or canceled and the calling thread is in an alertable wait state.
ReadFileScatter
Reads data from a file and stores it in an array of buffers.
RemoveUsersFromEncryptedFile
Removes specified certificate hashes from a specified file.
ReOpenFile
Reopens the specified file system object with different access rights, sharing mode, and flags.
ReplaceFile
Replaces one file with another file, with the option of creating a backup copy of the original file.
SearchPath
Searches for a specified file in a specified path.
SetEndOfFile
Sets the physical file size for the specified file to the current position of the file pointer.
SetFileApisToANSI
Causes the file I/O functions to use the ANSI character set code page for the current process.
SetFileApisToOEM
Causes the file I/O functions for the process to use the OEM character set code page.
SetFileAttributes
Sets the attributes for a file or directory.
SetFileAttributesTransacted
Sets the attributes for a file or directory as a transacted operation.
SetFileBandwidthReservation
Requests that bandwidth for the specified file stream be reserved. The reservation is specified as a number of bytes in a period of milliseconds for I/O requests on the specified file handle.
SetFileCompletionNotificationModes
Sets the notification modes for a file handle, allowing you to specify how completion notifications work for the specified file.
SetFileInformationByHandle
Sets the file information for the specified file.
SetFileIoOverlappedRange
Associates a virtual address range with the specified file handle.
SetFilePointer
Moves the file pointer of the specified file.
SetFilePointerEx
Moves the file pointer of the specified file.
SetFileShortName
Sets the short name for the specified file.
SetFileValidData
Sets the valid data length of the specified file. This function is useful in very limited scenarios. For more information, see the Remarks section.
SetSearchPathMode
Sets the per-process mode that the SearchPath function uses when locating files.
SetUserFileEncryptionKey
Sets the user's current key to the specified certificate.
UnlockFile
Unlocks a region in an open file.
UnlockFileEx
Unlocks a region in the specified file. This function can operate either synchronously or asynchronously.
WofEnumEntries
Enumerates all the data sources from a specified provider for a specified volume.
WofEnumEntryProc
Callback function that gets called for each data source in response to a call to WofEnumEntries.
WofEnumFilesProc
Callback function that gets called for each file backed by an external data source, such as a WIM file.
WofFileEnumFiles
Enumerates all of the files which are compressed with a specified compression algorithm on a specified volume.
WofGetDriverVersion
Used to query the version of the driver used to support a particular provider.
WofIsExternalFile
Used to determine if a file is being backed by a physical file or is backed by a system data provider, and optionally indicates which provider or additional data about the file.
WofSetFileDataLocation
Used to change a file from being backed by a physical file to one backed by a system data provider.
WofShouldCompressBinaries
Indicates whether compression should be used on a particular volume, and if so, which compression algorithm should be used.
WofWimAddEntry
Adds a single WIM data source to a volume such that files can be created on the volume which are stored within the WIM.
WofWimEnumFiles
Enumerates all of the files which are being backed by a specified WIM data source on a specified volume.
WofWimRemoveEntry
Removes a single WIM data source from backing files on a volume.
WofWimSuspendEntry
Temporarily removes a WIM data source from backing files on a volume until the volume is remounted or the data source is updated with WofWimUpdateEntry.
WofWimUpdateEntry
Updates a WIM entry to point to a different WIM file location.
Wow64DisableWow64FsRedirection
Disables file system redirection for the calling thread. File system redirection is enabled by default.
Wow64EnableWow64FsRedirection
Enables or disables file system redirection for the calling thread.
Wow64RevertWow64FsRedirection
Restores file system redirection for the calling thread.
WriteEncryptedFileRaw
Restores (import) encrypted files.
WriteFile
Writes data to the specified file or input/output (I/O) device.
WriteFileEx
Writes data to the specified file or input/output (I/O) device. It reports its completion status asynchronously, calling the specified completion routine when writing is completed or canceled and the calling thread is in an alertable wait state.
WriteFileGather
Retrieves data from an array of buffers and writes the data to a file.

The following functions are used with file I/O.

CancelIo
CancelIoEx
CancelSynchronousIo
CreateIoCompletionPort
FlushFileBuffers
GetQueuedCompletionStatus
GetQueuedCompletionStatusEx
LockFile
LockFileEx
PostQueuedCompletionStatus
ReadFile
ReadFileEx
ReadFileScatter
SetEndOfFile
SetFileCompletionNotificationModes
SetFileIoOverlappedRange
SetFilePointer
SetFilePointerEx
UnlockFile
UnlockFileEx
WriteFile
WriteFileEx
WriteFileGather

The following functions are used with the encrypted file system.

AddUsersToEncryptedFile
CloseEncryptedFileRaw
DecryptFile
DuplicateEncryptionInfoFile
EncryptFile
EncryptionDisable
FileEncryptionStatus
FreeEncryptionCertificateHashList
OpenEncryptedFileRaw
QueryRecoveryAgentsOnEncryptedFile
QueryUsersOnEncryptedFile
ReadEncryptedFileRaw
RemoveUsersFromEncryptedFile
SetUserFileEncryptionKey
WriteEncryptedFileRaw

The following functions are used with the file system redirector.

Wow64DisableWow64FsRedirection
Wow64EnableWow64FsRedirection
Wow64RevertWow64FsRedirection

The following functions are used to decompress files that are compressed by the Lempel-Ziv algorithm.

GetExpandedName
LZClose
LZCopy
LZInit
LZOpenFile
LZRead
LZSeek

The following callback functions are used in file I/O.

CopyProgressRoutine
ExportCallback
FileIOCompletionRoutine
ImportCallback