Click here to Skip to main content
14,865,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

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);         // Address of an SHFILEOPSTRUCT structure that contains information 
                                                // this function needs to carry out the specified operation. This 
                                                // parameter must contain a valid value that is not NULL. You are 
                                                // responsibile for validating the value. If you do not validate it, 
                                                // you will experience unexpected results. 

    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);

            case MachineType.win64:
                SHFILEOPSTRUCT64 fos64 = new SHFILEOPSTRUCT64(lpFileOp);
                result = SHFileOperation64(ref fos64);

                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:


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.

Updated 27-Oct-20 21:21pm
Gerry Schmitz 28-Oct-20 0:39am
So, it works, but you don't like the "progress bar". In the grand scheme of things ...
yoandryLumpuy 29-Oct-20 11:18am
Gerry It works perfectly that way, but the client is the boss and he wants the default copier to be activated because sometimes they provide better handling and behavior of the copies.

1 solution

If you want to use Supercopier, Teracopy, Ultracopier or another application, you have to:
1) call its exe via Process.Start[^].
2) install NuGet package and use it within your application. See: GitHub - alphaonex86/Supercopier: Deprecated, replaced by Ultracopier[^]
yoandryLumpuy 29-Oct-20 12:09pm
This way?:

var fileName1 = @"D:\text1.txt";
var fileName2 = @"D:\text2.txt";
var processStartInfo = new ProcessStartInfo
UseShellExecute = true,
Arguments = $"copy /B \"{fileName1}\" \"{fileName2}\"",
FileName = "cmd.exe",
WindowStyle = ProcessWindowStyle.Hidden


But this way doesn't even show the Windows progress bar when triggering the copy.
Even if Teracopy or one of those copiers could be activated by command line, that's not what I want, I want the copy to be activated by invoking windows and that it delegates it as desired to one of those copiers, without even knowing if there is one installed, otherwise use the default one. I don't know if so much demand in this functionality can be implemented, i can't find the way of doing it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900