/// <summary> /// Enables a handler to provide status and error information for all operations. /// </summary> /// <param name="pfops">An <see cref="IFileOperationProgressSink"/> object to be used for progress status and error notifications.</param> /// <returns>A returned token that uniquely identifies this connection. The calling application uses this token later to delete the connection by passing it to <see cref="Unadvise"/>.</returns> /// <remarks>Several individual methods have the ability to declare their own progress sinks, which are redundant to the one set here. They are used when you only want to be given progress and error information for a specific operation.</remarks> /// <exception cref="ArgumentNullException">Exception thrown when a parameter is null.</exception> /// <exception cref="ObjectDisposedException">Exception thrown when this object is disposed.</exception> /// <exception cref="Win32Exception">Exception thrown when this method fails because of an error in the Win32 COM API implementation.</exception> public uint Advise(FileOperationProgressSink pfops) { if (pfops == null) { throw new ArgumentNullException(nameof(pfops)); } if (disposed) { throw new ObjectDisposedException(nameof(FileOperation)); } HResult hr = fileOperation.Advise(pfops.FileOperationProgressSinkInternal, out uint pdwCookie); if (CoreErrorHelper.Succeeded(hr)) { cookies.Add(pdwCookie); return(pdwCookie); } else { Marshal.ThrowExceptionForHR((int)hr); } return(0); }
//public HResult CopyItems(object punkItems, IShellItem psiDestinationFolder) => throw new NotImplementedException(); public void DeleteItem(IShellItem psiItem, FileOperationProgressSink pfopsItem) { if (disposed) { throw new ObjectDisposedException(nameof(FileOperation)); } HResult hr = fileOperation.DeleteItem(psiItem, pfopsItem?.FileOperationProgressSinkInternal); if (!CoreErrorHelper.Succeeded(hr)) { Marshal.ThrowExceptionForHR((int)hr); } }
public FileOperationProgressSinkInternal(FileOperationProgressSink fileOperationProgressSink) => this.fileOperationProgressSink = fileOperationProgressSink;
public void NewItem(ShellObject destinationFolder, FileAttributes fileAttributes, string name, string templateName, FileOperationProgressSink pfopsItem) => NewItem(destinationFolder.NativeShellItem, fileAttributes, name, templateName, pfopsItem);
//public HResult DeleteItems(object punkItems) => throw new NotImplementedException(); public void NewItem(IShellItem psiDestinationFolder, FileAttributes dwFileAttributes, string pszName, string pszTemplateName, FileOperationProgressSink pfopsItem) { if (disposed) { throw new ObjectDisposedException(nameof(FileOperation)); } HResult hr = fileOperation.NewItem(psiDestinationFolder, dwFileAttributes, pszName, pszTemplateName, pfopsItem?.FileOperationProgressSinkInternal); if (!CoreErrorHelper.Succeeded(hr)) { Marshal.ThrowExceptionForHR((int)hr); } }
public void DeleteItem(ShellObject shellObject, FileOperationProgressSink pfopsItem) => DeleteItem(shellObject.NativeShellItem, pfopsItem);
public void CopyItem(ShellObject shellObject, ShellObject destinationFolder, string copyName, FileOperationProgressSink pfopsItem) => CopyItem(shellObject.NativeShellItem, destinationFolder.NativeShellItem, copyName, pfopsItem);
//public HResult MoveItems(object punkItems, IShellItem psiDestinationFolder) => throw new NotImplementedException(); public void CopyItem(IShellItem psiItem, IShellItem psiDestinationFolder, string pszCopyName, FileOperationProgressSink pfopsItem) { if (disposed) { throw new ObjectDisposedException(nameof(FileOperation)); } HResult hr = fileOperation.CopyItem(psiItem, psiDestinationFolder, pszCopyName, pfopsItem?.FileOperationProgressSinkInternal); if (!CoreErrorHelper.Succeeded(hr)) { Marshal.ThrowExceptionForHR((int)hr); } }
public void MoveItem(ShellObject shellObject, ShellObject destinationShellObject, string newName, FileOperationProgressSink pfopsItem) => MoveItem(shellObject.NativeShellItem, destinationShellObject.NativeShellItem, newName, pfopsItem);
public void RenameItem(ShellObject shellObject, string newName, FileOperationProgressSink pfopsItem) => RenameItem(shellObject.NativeShellItem, newName, pfopsItem);