IStorage::MoveElementTo method

The MoveElementTo method copies or moves a substorage or stream from this storage object to another storage object.


HRESULT MoveElementTo(
  const OLECHAR *pwcsName,
  IStorage      *pstgDest,
  const OLECHAR *pwcsNewName,
  DWORD         grfFlags



Pointer to a wide character null-terminated Unicode string that contains the name of the element in this storage object to be moved or copied.


IStorage pointer to the destination storage object.


Pointer to a wide character null-terminated unicode string that contains the new name for the element in its new storage object.


Specifies whether the operation should be a move (STGMOVE_MOVE) or a copy (STGMOVE_COPY). See the STGMOVE enumeration.

Return value

This method can return one of these values.


The IStorage::MoveElementTo method is typically the same as invoking the IStorage::CopyTo method on the indicated element and then removing the source element. In this case, the MoveElementTo method uses only the publicly available functions of the destination storage object to carry out the move.

If the source and destination storage objects have special knowledge about each other's implementation (they could, for example, be different instances of the same implementation), this method can be implemented more efficiently.

Before calling this method, the element to be moved must be closed, and the destination storage must be open. Also, the destination object and element cannot be the same storage object/element name as the source of the move. That is, you cannot move an element to itself.


Minimum supported client Windows 2000 Professional [desktop apps | UWP apps]
Minimum supported server Windows 2000 Server [desktop apps | UWP apps]
Target Platform Windows
Header objidl.h
Library Uuid.lib
DLL Ole32.dll

See also

IStorage - Compound File Implementation