CopyFileFromHostToGuest with large files (800MB+?)

Jun 7, 2011 at 1:44 PM

I am having trouble getting the following to work when dealing with large files, where the "limit" is I don't know yet, but at least a 1.1GB file failed as well as a 800+ MB file.

Failed is as much said however, what happens is simply that the operation loops, meaning it gets up and over the file size in the Guest and then it starts over.


Have anyone experienced the same issue and know of a fix?

Method used is:


Jun 8, 2011 at 12:49 AM

That API is so slow. I was never able to copy anything that's large across the wire with any repeatable success rate. I went a different approach. That has since been integrated into VMWareTasks. Here's how to do the equivalent of "net use", then you can just do File.copy.

                MappedNetworkDriveInfo mappedNetworkDriveInfo = new MappedNetworkDriveInfo();
                mappedNetworkDriveInfo.RemotePath = @"C:\";
                mappedNetworkDriveInfo.Username = provider.Username;
                mappedNetworkDriveInfo.Password = provider.Password;
                Console.WriteLine("Remote IP: {0}", vm.GuestVariables["ip"]);
                using (MappedNetworkDrive mappedNetworkDrive = new MappedNetworkDrive(
                    vm, mappedNetworkDriveInfo))
                    string guestWindowsPath = mappedNetworkDrive.GuestPathToNetworkPath(@"C:\Windows");
                    Console.WriteLine("Mapped windows directory: {0}", guestWindowsPath);
                    Shell guestShell = new Shell(provider.PoweredVirtualMachine);
                    Assert.AreEqual(string.Format(@"\\{0}\C$\Windows", guestShell.IpAddress), guestWindowsPath);