Exemplo n.º 1
0
        /// <summary>
        /// Copies a file from the host machine to the virtual machine
        /// </summary>
        /// <param name=”sourceFile”>The source file on the host machine</param>
        /// <param name=”destinationFile”>The destination on the VM</param>
        /// <returns>true if succeeded, otherwise false</returns>
        public bool CopyFileToVm(string sourceFile, string destinationFile)
        {
            //
            // Copy files from host to guest
            //
            IJob jobHandle = m_vmHandle.CopyFileFromHostToGuest(sourceFile, destinationFile,
                                                                0, null, null);

            m_vixError = jobHandle.WaitWithoutResults();

            return(m_vixError == VixCOM.Constants.VIX_OK);
        }
Exemplo n.º 2
0
        public void CopyFileToGuest(string source, string destination)
        {
            if (!File.Exists(source))
            {
                throw new Exception("CopyFileToGuest: The source file " + source + " does not exist.");
            }

            VixCOM.IJob job = _virtualMachine.CopyFileFromHostToGuest(source, destination, 0, null, null);
            UInt64      err = job.WaitWithoutResults();

            if (lib.ErrorIndicatesFailure(err))
            {
                short  errCode = lib.ErrorCode(err);
                string errMsg;
                errMsg = lib.GetErrorText(err, null);

                throw new Exception("CopyFileToGuest: " + errMsg);
            }
        }