I really like VMWare VIX API’s CopyFileFromGuestToHost and CopyFileFromHostToGuest. These automatically copy a single file or an entire directory tree. Easy. Unfortunately I am copying large (150-300 Mb) files to/from a VMWare guest OS and it’s taking an hour to copy a hundred megs. I bet VMWare API was developed by Russian developers, so it’s probably sending UTF-8 encoded bytes in Russian via SOAP. You might remember that I am writing a tool that lets one test a cross-product of installers and virtual machine snapshots: three MSIs multipled by twenty snapshots equals days of file copying! It’s not going to work.
I posted a question about this in VMWare Communities and got a satisfactory response: I don’t think there is a workaround. We are aware of the issue (we run in to it internally) and hope to fix it in a future release.
In the meantime, I need a short term solution.
I decided to try and map the remote drive and use a simple File.Copy. The first challenge is to find out the remote server’s IP address. VMWare exposes guest OS variables, including the ip, so I’ve extended VMWareTasks to support those.
Here’s the IP address of a powered-on VM.
We can make up a network path out of a local one.
Mapping a network drive is implemented in mpr.dll with WNetAddConnection2. A wrapper class will do the job.
Let’s put it all together.
The last thing that remains to be done to make the new copy compatible is to also copy directories and subdirectories. That’s left as an exercise to the reader.