IOfflineFilesCache::DeleteItemsForUser method

Deletes a user's files and directories from the local cache. Deleting a container item implies deletion of all its contained items, recursively.

Syntax

HRESULT DeleteItemsForUser(
  LPCWSTR                     pszUser,
  LPCWSTR                     *rgpszPaths,
  ULONG                       cPaths,
  DWORD                       dwFlags,
  BOOL                        bAsync,
  IOfflineFilesSimpleProgress *pIProgress
);

Parameters

pszUser

Text string identifying the user for which the files are to be deleted for. This option is available only to administrators on the local computer. The text string may be the user's SID in string format or the user's domain\user logon name string.

rgpszPaths

Array of pointers, each to a fully qualified UNC path of a file or directory to be deleted.

cPaths

Number of paths in rgpszPaths.

dwFlags

Flags controlling the behavior of the delete operation. This parameter can be one or more of the following values.

OFFLINEFILES_DELETE_FLAG_NOAUTOCACHED (0x00000001)

Do not delete automatically cached items. The default behavior is to delete automatically cached items.

OFFLINEFILES_DELETE_FLAG_NOPINNED (0x00000002)

Do not delete pinned items. The default behavior is to delete pinned items.

OFFLINEFILES_DELETE_FLAG_DELMODIFIED (0x00000004)

Delete even if locally modified in the cache. The default behavior is to not delete files with unsynchronized local changes.

OFFLINEFILES_DELETE_FLAG_ADMIN (0x80000000)

Allows administrators to enumerate and delete all files regardless of access rights. If this flag is set and the caller is not an administrator, the function fails.

bAsync

Indicates whether the operation is to be performed asynchronously. If this parameter is TRUE, the operation is scheduled for asynchronous operation and the function returns immediately. If this parameter is FALSE, the function returns when the operation is complete.

pIProgress

Interface to an event sink that will receive progress events during the operation. If events are not desired, this parameter can be NULL. Providing an event sink is highly recommended for asynchronous operation. A progress implementation is the only way to be notified when the asynchronous operation completes.

Return Value

Returns S_OK if successful, or an error value otherwise.

Returns HRESULT_FROM_WIN32(ERROR_CANCELLED) if the operation is canceled. Returns HRESULT_FROM_WIN32(ERROR_MORE_DATA) if errors occurred during the operation. Use the IOfflineFilesSimpleProgress::ItemResult callback method to detect errors as they occur.

Remarks

The caller must have sufficient access to the files and directories to be deleted.

If a delete operation is canceled while in progress, changes to files processed to that point are not rolled back.

If a delete operation on a directory cannot remove all of its contained files or directories (for example, if access is denied), the specified directory entry is not removed. Any files and directories deleted up to that point remain deleted.

Files are deleted only from the local cache. Associated files on the network server are not affected.

Files deleted are not recoverable through the Recycle Bin. Files deleted must be recached to be available offline.

If only one path is provided in the rgpszPaths parameter and that path is to a single file, the return value indicates the result of that single delete operation. Otherwise, the caller must implement the progress callback methods in the following list and monitor the IOfflineFilesSimpleProgress::ItemResult method to obtain the result for each processed file and directory.

Progress Events Interface Method Description
IOfflineFilesProgress Begin Called at the start of the operation.
IOfflineFilesSyncProgress SyncItemBegin Called at the start of processing for each file.
IOfflineFilesSyncProgress SyncItemResult Called after each file is deleted.
IOfflineFilesProgress QueryAbort Called periodically during the sync operation to detect a request for cancellation.
IOfflineFilesProgress End Called at the end of the operation.

Requirements

   
Windows version Windows Vista Windows Server 2008
Target Platform Windows
Header cscobj.h
DLL CscSvc.dll; CscObj.dll

See Also

IOfflineFilesCache