• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 813
  • Last Modified:

Copy a file using Volume Shadow Service

I am using Visual Studio 2008 working with VB.NET.

What I want to do is create a small app for myself that can make a copy of some of my files which are often locked by the system.

I'm told this can be done in a way, you can get a copy of whats written on the disk by accessing a snapshot of the file using the volume shadow service. I understand this may not be the entire file if data hasn't yet been written.

Can anyone provide me with a function which can access the VSS API for XP or Vista where I can pass it the path/name of the source file and the path/name of the destination file and have it make the copy?

Cheers.
0
Andy1
Asked:
Andy1
  • 2
1 Solution
 
ChetOS82Commented:
Have you looked at the Volume Shadow Service SDK?  http://www.microsoft.com/downloads/details.aspx?FamilyID=0b4f56e4-0ccc-4626-826a-ed2c4c95c871&DisplayLang=en

Also, there is a CodeProject page giving a use like yours: http://www.codeproject.com/KB/dotnet/makeshadowcopy.aspx
0
 
Andy1Author Commented:
I still haven't gotten far with this... i had already downloaded the sdk.
0
 
Andy1Author Commented:
I had already downloaded the SDK you link to.

The CodeProject page just had lots of errors... not sure if its because im using Visual Studio 2008 but I wasn't able to make it work. - This may also be because im using Vista.. not sure if that code is XP only.

I'd still love a way to implement this proramitically.

What I've found in my trolling of MSDN and the internet I found a reference to the latest Windows SDK which had some more information about the Volume shadow copy service.

If i've understood it correctly, theres some incompatibilities between versions - so a program has to be compiled for each OS (XP, 2003 or Vista(and above)) version you want to run on.

In the SDK as linked above, there is 2 compiled programs: 'vshadow.exe' for XP or 2003 server. In the Windows SDK I found a compled version of vshadow.exe for Vista and above.

So while I would still love some code that can do it all programitically, I've had to go with the following solution:

Having all 3 versions of vshadow.exe
Detect the OS version
Interact with the OS's version of vshadow.exe to create the copy of the file.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now