469,568 Members | 1,576 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

Shadow Copy Wrapper?

CMM
I've been scouring the net for the last few days looking for a way to copy a
locked file (create a shadow volume, expose it... that's it) from within my
program. I'm aware of the kludgy vshadow.exe commandline tool, but what I
really need is to be able to do it in managed code or via API's. I'm also
aware of the VSS SDK so I don't need a pointer to them.... just wondering if
anyone has had experience with this.

Nov 14 '07 #1
9 2253
Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of using it

did u check how that sample meets your needs?

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
CI've been scouring the net for the last few days looking for a way to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>
Nov 14 '07 #2
"CMM" <cm*@nospam.comwrote in message
news:19**********************************@microsof t.com...
I've been scouring the net for the last few days looking for a way to copy
a locked file (create a shadow volume, expose it... that's it) from within
my program. I'm aware of the kludgy vshadow.exe commandline tool, but what
I really need is to be able to do it in managed code or via API's. I'm
also aware of the VSS SDK so I don't need a pointer to them.... just
wondering if anyone has had experience with this.

The VSS API's are a set of COM and C++ interfaces, none of them are directly
accessible from C#, so you'll have to write a wrapper in C++/CLI to be able
to access them from pure managed code.
Note however that using VSS only because you need to copy a locked file is
overkill, you can achieve the same functionality by using PInvoke to call
some Win32 API's.

First you need to open the file using Win32 "CreateFile" API with:
dwDesiredACcess = 0
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE
and dwFlagsAndAttributes = FILE_FLAG_BACKUP_SEMANTICS set.
The file handle returned can be used to call the "Kernel32" Backup API's
like "BackupRead", "BackupSeek" etc....
Note that this all requires the right privileges (SeBackupPrivilege) for the
caller!

Willy.

Nov 14 '07 #3
CMM
I was under the impression that the samples are C++ and not exactly portable
to the managed world. It's a shame too... because VShadow.exe... with a
little effort on the VSS team could probably be retooled into a useful
class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsoft .com...
Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of using
it

did u check how that sample meets your needs?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

CI've been scouring the net for the last few days looking for a way to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>
Nov 14 '07 #4
The VSS team is not owning the SDK and it's samples, nor do they care about
managed code, the API is exposed through COM and C++ interfaces just like
the VSS Service. Writing a managed wrapper in C++/CLI isn't that hard
anyway. Note that as I said in another reply, you don't need VSS for this at
all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@microsof t.com...
>I was under the impression that the samples are C++ and not exactly
portable to the managed world. It's a shame too... because VShadow.exe...
with a little effort on the VSS team could probably be retooled into a
useful class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsoft .com...
>Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of using
it

did u check how that sample meets your needs?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and
we miss it, but that it is too low and we reach it" (c) Michelangelo

CI've been scouring the net for the last few days looking for a way to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>

Nov 14 '07 #5
CMM
I don't need VSS at all? So BackupRead will alert the file's owner to flush
the file like VSS does? What if the actual copying is being done by code
other than mine? Ideally, I want to create the snapshot, pass the exposed
volume to the component to handle the rest, etc. Anyway, I was looking for a
simple solution. Looks like calling vshadow.exe and scripting it will end up
being the way to go. Shame.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
The VSS team is not owning the SDK and it's samples, nor do they care
about managed code, the API is exposed through COM and C++ interfaces just
like the VSS Service. Writing a managed wrapper in C++/CLI isn't that hard
anyway. Note that as I said in another reply, you don't need VSS for this
at all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@microsof t.com...
>>I was under the impression that the samples are C++ and not exactly
portable to the managed world. It's a shame too... because VShadow.exe...
with a little effort on the VSS team could probably be retooled into a
useful class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsof t.com...
>>Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of using
it

did u check how that sample meets your needs?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and
we miss it, but that it is too low and we reach it" (c) Michelangelo

CI've been scouring the net for the last few days looking for a way to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>

Nov 14 '07 #6
"CMM" <cm*@nospam.comwrote in message
news:80**********************************@microsof t.com...
>I don't need VSS at all? So BackupRead will alert the file's owner to flush
the file like VSS does? What if the actual copying is being done by code
other than mine? Ideally, I want to create the snapshot, pass the exposed
volume to the component to handle the rest, etc. Anyway, I was looking for
a simple solution. Looks like calling vshadow.exe and scripting it will end
up being the way to go. Shame.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
>The VSS team is not owning the SDK and it's samples, nor do they care
about managed code, the API is exposed through COM and C++ interfaces
just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
that hard anyway. Note that as I said in another reply, you don't need
VSS for this at all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@microso ft.com...
>>>I was under the impression that the samples are C++ and not exactly
portable to the managed world. It's a shame too... because VShadow.exe...
with a little effort on the VSS team could probably be retooled into a
useful class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microso ft.com...
Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of
using it

did u check how that sample meets your needs?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and
we miss it, but that it is too low and we reach it" (c) Michelangelo

CI've been scouring the net for the last few days looking for a way
to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>



Nov 14 '07 #7
VSS can't alert the owning program unless this one implements the VSWriter
interfaces. That means that the application needs to be modified for this.
When the application does not implement VSWriter, the File System will
simply be "alerted" to flush the FS buffers, but this is no guaranteed to be
free of incomplete I/Writer operations and data corruption, the shadow image
is said to be in a "Crash-Consistent state". If you need application
recovery state, you have to implement a writer in the application owning the
file(s).

Willy.
"CMM" <cm*@nospam.comwrote in message
news:80**********************************@microsof t.com...
>I don't need VSS at all? So BackupRead will alert the file's owner to flush
the file like VSS does? What if the actual copying is being done by code
other than mine? Ideally, I want to create the snapshot, pass the exposed
volume to the component to handle the rest, etc. Anyway, I was looking for
a simple solution. Looks like calling vshadow.exe and scripting it will end
up being the way to go. Shame.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
>The VSS team is not owning the SDK and it's samples, nor do they care
about managed code, the API is exposed through COM and C++ interfaces
just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
that hard anyway. Note that as I said in another reply, you don't need
VSS for this at all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@microso ft.com...
>>>I was under the impression that the samples are C++ and not exactly
portable to the managed world. It's a shame too... because VShadow.exe...
with a little effort on the VSS team could probably be retooled into a
useful class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microso ft.com...
Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of
using it

did u check how that sample meets your needs?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and
we miss it, but that it is too low and we reach it" (c) Michelangelo

CI've been scouring the net for the last few days looking for a way
to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>



Nov 14 '07 #8
CMM
Yes, I'm aware of that. The question remains: there is no way, no working
examples, and no experience with using C# or VB.NET to create and expose a
shadow snapshot of a volume, right?

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:eM*************@TK2MSFTNGP06.phx.gbl...
VSS can't alert the owning program unless this one implements the VSWriter
interfaces. That means that the application needs to be modified for this.
When the application does not implement VSWriter, the File System will
simply be "alerted" to flush the FS buffers, but this is no guaranteed to
be free of incomplete I/Writer operations and data corruption, the shadow
image is said to be in a "Crash-Consistent state". If you need application
recovery state, you have to implement a writer in the application owning
the file(s).

Willy.
"CMM" <cm*@nospam.comwrote in message
news:80**********************************@microsof t.com...
>>I don't need VSS at all? So BackupRead will alert the file's owner to
flush the file like VSS does? What if the actual copying is being done by
code other than mine? Ideally, I want to create the snapshot, pass the
exposed volume to the component to handle the rest, etc. Anyway, I was
looking for a simple solution. Looks like calling vshadow.exe and
scripting it will end up being the way to go. Shame.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
>>The VSS team is not owning the SDK and it's samples, nor do they care
about managed code, the API is exposed through COM and C++ interfaces
just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
that hard anyway. Note that as I said in another reply, you don't need
VSS for this at all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@micros oft.com...
I was under the impression that the samples are C++ and not exactly
portable to the managed world. It's a shame too... because
VShadow.exe... with a little effort on the VSS team could probably be
retooled into a useful class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.micros oft.com...
Hello CMM,
>
if u aware about VSS SDK, u should noted that there is a sample of
using it
>
did u check how that sample meets your needs?
>
---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we miss it, but that it is too low and we reach it" (c)
Michelangelo
>
CI've been scouring the net for the last few days looking for a way
to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>
>

Nov 14 '07 #9
That's right because like I have said, the VSS interfaces are not directly
usable from "pure" managed code, you have to write a wrapper in C++/CLI
(mixed managed unmanaged code) for this.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:90**********************************@microsof t.com...
Yes, I'm aware of that. The question remains: there is no way, no working
examples, and no experience with using C# or VB.NET to create and expose a
shadow snapshot of a volume, right?
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:eM*************@TK2MSFTNGP06.phx.gbl...
>VSS can't alert the owning program unless this one implements the
VSWriter interfaces. That means that the application needs to be modified
for this. When the application does not implement VSWriter, the File
System will simply be "alerted" to flush the FS buffers, but this is no
guaranteed to be free of incomplete I/Writer operations and data
corruption, the shadow image is said to be in a "Crash-Consistent state".
If you need application recovery state, you have to implement a writer in
the application owning the file(s).

Willy.
"CMM" <cm*@nospam.comwrote in message
news:80**********************************@microso ft.com...
>>>I don't need VSS at all? So BackupRead will alert the file's owner to
flush the file like VSS does? What if the actual copying is being done by
code other than mine? Ideally, I want to create the snapshot, pass the
exposed volume to the component to handle the rest, etc. Anyway, I was
looking for a simple solution. Looks like calling vshadow.exe and
scripting it will end up being the way to go. Shame.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
The VSS team is not owning the SDK and it's samples, nor do they care
about managed code, the API is exposed through COM and C++ interfaces
just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
that hard anyway. Note that as I said in another reply, you don't need
VSS for this at all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@micro soft.com...
>I was under the impression that the samples are C++ and not exactly
>portable to the managed world. It's a shame too... because
>VShadow.exe... with a little effort on the VSS team could probably be
>retooled into a useful class.
>
>
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.micro soft.com...
>Hello CMM,
>>
>if u aware about VSS SDK, u should noted that there is a sample of
>using it
>>
>did u check how that sample meets your needs?
>>
>---
>WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
>http://spaces.live.com/laflour
>"The greatest danger for most of us is not that our aim is too high
>and we miss it, but that it is too low and we reach it" (c)
>Michelangelo
>>
>CI've been scouring the net for the last few days looking for a way
>to
>Ccopy a locked file (create a shadow volume, expose it... that's
>it)
>Cfrom within my program. I'm aware of the kludgy vshadow.exe
>Ccommandline tool, but what I really need is to be able to do it in
>Cmanaged code or via API's. I'm also aware of the VSS SDK so I
>don't
>Cneed a pointer to them.... just wondering if anyone has had
>Cexperience with this.
>C>
>>
>


Nov 14 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Nik Thomas | last post: by
4 posts views Thread by Barry Kelly | last post: by
reply views Thread by Damien Anselmi | last post: by
reply views Thread by Patrick F | last post: by
1 post views Thread by Patrick F | last post: by
9 posts views Thread by CMM | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.