473,321 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

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 3472
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Nik Thomas | last post by:
I'm beginning to redesign my site to move away from table-based layouts, and to incorporate a decent amount of cross-browser reliability, graceful degradation and standards compliance. I have...
3
by: surajitkhan | last post by:
Hi Can anyone tell me how to make a drop shadow for a table or td through css. I dont want to use any image. I want it done through background color. Thanks Surajit
5
by: Bill Rust | last post by:
I have a component that needs to access files which exist in the same directory as the DLL containing the component itself. To determine the component's installation directory, I'm using...
4
by: Barry Kelly | last post by:
I'm designing an application framework which will, amongst other things, live in an assembly hosted in the ASP.NET worker process, servicing webservice requests. Here's the scenario: APPFX is...
0
by: Damien Anselmi | last post by:
I am using the CompileAssemblyFromSource method of an ICodeCompiler instance to dynamically compile an assembly used by a Web Application. The assembly may be recompiled any number of times during...
1
by: supriya | last post by:
Hi, I found vshadow sdk in MSDN.I am unable to use the shadow copy for backup and restore because it is creating only non persistent shadow copy in winxp.How can i create persistent shadow copy...
2
by: Diffident | last post by:
Hello All, I just finished reading an interesting article by Scott about App Domains: http://odetocode.com/Articles/305.aspx Scott, I have a question about the section "Shadow Copies and...
0
by: Patrick F | last post by:
I keep getting this error message and i don't know whats the problem is and how to solve it. I have a webproject with 2 components (dll) added to it. One is called PhotoGallery and one is called...
1
by: Patrick F | last post by:
I keep getting this error message and i don't know whats the problem is and how to solve it. I have a webproject with 2 components (dll) added to it. One is called PhotoGallery and one is called...
9
by: CMM | last post by:
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.