IFileOperation::SetOperationFlags method (shobjidl_core.h)

Sets parameters for the current operation.


HRESULT SetOperationFlags(
  [in] DWORD dwOperationFlags


[in] dwOperationFlags


Flags that control the file operation. This member can be a combination of the following flags. FOF flags are defined in Shellapi.h and FOFX flags are defined in Shobjidl.h.

Note  If this method is not called, the default value used by the operation is FOF_ALLOWUNDO | FOF_NOCONFIRMMKDIR.


Preserve undo information, if possible.

Prior to Windows Vista, operations could be undone only from the same process that performed the original operation.

In Windows Vista and later systems, the scope of the undo is a user session. Any process running in the user session can undo another operation. The undo state is held in the Explorer.exe process, and as long as that process is running, it can coordinate the undo functions.

If the source file parameter does not contain fully qualified path and file names, this flag is ignored.


Perform the operation only on files (not on folders) if a wildcard file name (.) is specified.


Respond with Yes to All for any dialog box that is displayed.


Do not confirm the creation of a new folder if the operation requires one to be created.


Do not move connected items as a group. Only move the specified files.


Do not copy the security attributes of the item.


Do not display a message to the user if an error occurs. If this flag is set without FOFX_EARLYFAILURE, any error is treated as if the user had chosen Ignore or Continue in a dialog box. It halts the current action, sets a flag to indicate that an action was aborted, and proceeds with the rest of the operation.


Only operate in the local folder. Do not operate recursively into subdirectories.


Give the item being operated on a new name in a move, copy, or rename operation if an item with the target name already exists.

FOF_SILENT (0x0004)

Do not display a progress dialog box.


Send a warning if a file or folder is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.


Introduced in Windows 8. The file operation was user-invoked and should be placed on the undo stack. This flag is preferred to FOF_ALLOWUNDO.


Walk into Shell namespace junctions. By default, junctions are not entered. For more information on junctions, see Specifying a Namespace Extension's Location.

If possible, create a hard link rather than a new instance of the file in the destination.


If an operation requires elevated rights and the FOF_NOERRORUI flag is set to disable error UI, display a UAC UI prompt nonetheless.


If FOFX_EARLYFAILURE is set together with FOF_NOERRORUI, the entire set of operations is stopped upon encountering any error in any operation. This flag is valid only when FOF_NOERRORUI is set.


Rename collisions in such a way as to preserve file name extensions. This flag is valid only when FOF_RENAMEONCOLLISION is also set.


Keep the newer file or folder, based on the Date Modified property, if a collision occurs. This is done automatically with no prompt UI presented to the user.


Do not use copy hooks.


Do not allow the progress dialog to be minimized.


Copy the security attributes of the source item to the destination item when performing a cross-volume move operation. Without this flag, the destination item receives the security attributes of its new folder.


Do not display the path of the source item in the progress dialog.


Do not display the path of the destination item in the progress dialog.


Introduced in Windows 8. When a file is deleted, send it to the Recycle Bin rather than permanently deleting it.


Introduced in Windows Vista SP1. The user expects a requirement for rights elevation, so do not display a dialog box asking for a confirmation of the elevation.


Introduced in Windows 7. Display a Downloading instead of Copying message in the progress dialog.


Introduced in Windows 7. Do not display the location line in the progress dialog.

Return value


If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


Set these flags before you call IFileOperation::PerformOperations to define the parameters for whatever operations are being performed, such as copy, delete, or rename.


Minimum supported client Windows Vista, Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header shobjidl_core.h (include Shobjidl.h)