file system and block level copy

Hi,

VMWare virtual disk i.e .vmdk consists of base .vmdk file containing header
and other .vmdk file containing the actual image.

I am writing an application to clone/copy an existing image.

In my application I create my own .vmdk header and then use CopyFile API to
copy the existing .vmdk image file to a new one.

After the above oeprations are completed, if I try to create a VM out of
the newly created image file, which fails.

But if, instead of usign CopyFIle API, I rightclick->copy/paste on old
image file to create a new image file, then VM can be created successfully
with new image file.

I have understanding that right click->copy/paste works at file system
level, just like the CopyFile API. Is my understanding correct here or
rightclick->copy/paste works at the volume block level while copying files
and directories. If thats the case, that can explain why I am facing this
problem.

Thanks
Anshul Makkar

CopyFile is a very high level API that does a lot of things under the hood. Have you tried to checksum the source file, the result of your copy by CopyFile and by explorer copy/paste? Does CopyFile produce a sparse file by chance, or some unexpected security attributes?

– pa