I need to route the information about a file copy in such a way that the default copier that is installed is triggered. I did it with the SHFileOperation function from the windows shell api and it worked for me but only with the windows copier, not with the supercopier or any other copier installed.
What I have tried:
The following code performs the task but invokes the progress bar of windows explorer:
[DllImport("shell32.dll", CharSet = CharSet.Unicode, EntryPoint = "SHFileOperation")]
public static extern Int32 SHFileOperation32(
ref SHFILEOPSTRUCT32 lpFileOp);
[DllImport("shell32.dll", CharSet = CharSet.Unicode, EntryPoint = "SHFileOperation")]
public static extern Int32 SHFileOperation64(
ref SHFILEOPSTRUCT64 lpFileOp);
public static Int32 SHFileOperation(ref SHFILEOPSTRUCT lpFileOp)
{
MachineType mt = GetMachineType();
Int32 result;
switch (mt)
{
case MachineType.win32:
SHFILEOPSTRUCT32 fos32 = new SHFILEOPSTRUCT32(lpFileOp);
result = SHFileOperation32(ref fos32);
lpFileOp.CopyFrom(fos32);
break;
case MachineType.win64:
SHFILEOPSTRUCT64 fos64 = new SHFILEOPSTRUCT64(lpFileOp);
result = SHFileOperation64(ref fos64);
lpFileOp.CopyFrom(fos64);
break;
default:
throw new ArgumentException("What kind of computer are you using? It's not 32 and not 64 bit");
}
return result;
}
The effect of showing the windows progress bar can also be achieved by the following code:
Microsoft.VisualBasic.FileIO.FileSystem.CopyFile(
@"D:\file1.txt",
@"D:\file2.txt",UIOption.AllDialogs);
But this is not the desired functionality. What is desired is to invoke the installed windows copier such as Supercopier, Teracopy, Ultracopier or another. It is evident that these tools implement an extension of the Windows Shell and make a customization of the copy process. I've been looking at the code on GitHub for some of these tools to see the copy hook handler they implement and I can't find a way to achieve my goald.
I need to invoke the windows shell in such a way that these copiers detect the event and handle it in their own way. If anyone has a suggestion it would be welcome.