Home All Groups Group Topic Archive Search About
Author
14 Nov 2007 6:20 AM
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.

Author
14 Nov 2007 12:36 PM
Michael Nemtsev [MVP]
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


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


Show quoteHide quote
"Michael Nemtsev [MVP]" <nemt***@msn.com> wrote in message
news:3d9fba1a1a30e8c9f52e51e6db50@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
>
> C> I've been scouring the net for the last few days looking for a way to
> C> copy a locked file (create a shadow volume, expose it... that's it)
> C> from within my program. I'm aware of the kludgy vshadow.exe
> C> commandline tool, but what I really need is to be able to do it in
> C> managed code or via API's. I'm also aware of the VSS SDK so I don't
> C> need a pointer to them.... just wondering if anyone has had
> C> experience with this.
> C>
>
Author
14 Nov 2007 3:35 PM
Willy Denoyette [MVP]
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.



Show quoteHide quote
"CMM" <cmm@nospam.com> wrote in message
news:8EC5E46B-8521-45C5-936D-961122E5C44A@microsoft.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]" <nemt***@msn.com> wrote in message
> news:3d9fba1a1a30e8c9f52e51e6db50@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
>>
>> C> I've been scouring the net for the last few days looking for a way to
>> C> copy a locked file (create a shadow volume, expose it... that's it)
>> C> from within my program. I'm aware of the kludgy vshadow.exe
>> C> commandline tool, but what I really need is to be able to do it in
>> C> managed code or via API's. I'm also aware of the VSS SDK so I don't
>> C> need a pointer to them.... just wondering if anyone has had
>> C> experience with this.
>> C>
>>
>
Author
14 Nov 2007 3:58 PM
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.

Show quoteHide quote
"Willy Denoyette [MVP]" <willy.denoye***@telenet.be> wrote in message
news:uRdSvPtJIHA.5400@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" <cmm@nospam.com> wrote in message
> news:8EC5E46B-8521-45C5-936D-961122E5C44A@microsoft.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]" <nemt***@msn.com> wrote in message
>> news:3d9fba1a1a30e8c9f52e51e6db50@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
>>>
>>> C> I've been scouring the net for the last few days looking for a way to
>>> C> copy a locked file (create a shadow volume, expose it... that's it)
>>> C> from within my program. I'm aware of the kludgy vshadow.exe
>>> C> commandline tool, but what I really need is to be able to do it in
>>> C> managed code or via API's. I'm also aware of the VSS SDK so I don't
>>> C> need a pointer to them.... just wondering if anyone has had
>>> C> experience with this.
>>> C>
>>>
>>
>
>
Author
14 Nov 2007 9:00 PM
Willy Denoyette [MVP]
Show quote Hide quote
"CMM" <cmm@nospam.com> wrote in message
news:809EF727-4CB5-4DF6-9459-F5EB4B37F2D0@microsoft.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]" <willy.denoye***@telenet.be> wrote in message
> news:uRdSvPtJIHA.5400@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" <cmm@nospam.com> wrote in message
>> news:8EC5E46B-8521-45C5-936D-961122E5C44A@microsoft.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]" <nemt***@msn.com> wrote in message
>>> news:3d9fba1a1a30e8c9f52e51e6db50@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
>>>>
>>>> C> I've been scouring the net for the last few days looking for a way
>>>> to
>>>> C> copy a locked file (create a shadow volume, expose it... that's it)
>>>> C> from within my program. I'm aware of the kludgy vshadow.exe
>>>> C> commandline tool, but what I really need is to be able to do it in
>>>> C> managed code or via API's. I'm also aware of the VSS SDK so I don't
>>>> C> need a pointer to them.... just wondering if anyone has had
>>>> C> experience with this.
>>>> C>
>>>>
>>>
>>
>>
>
Author
14 Nov 2007 9:13 PM
Willy Denoyette [MVP]
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.


Show quoteHide quote
"CMM" <cmm@nospam.com> wrote in message
news:809EF727-4CB5-4DF6-9459-F5EB4B37F2D0@microsoft.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]" <willy.denoye***@telenet.be> wrote in message
> news:uRdSvPtJIHA.5400@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" <cmm@nospam.com> wrote in message
>> news:8EC5E46B-8521-45C5-936D-961122E5C44A@microsoft.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]" <nemt***@msn.com> wrote in message
>>> news:3d9fba1a1a30e8c9f52e51e6db50@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
>>>>
>>>> C> I've been scouring the net for the last few days looking for a way
>>>> to
>>>> C> copy a locked file (create a shadow volume, expose it... that's it)
>>>> C> from within my program. I'm aware of the kludgy vshadow.exe
>>>> C> commandline tool, but what I really need is to be able to do it in
>>>> C> managed code or via API's. I'm also aware of the VSS SDK so I don't
>>>> C> need a pointer to them.... just wondering if anyone has had
>>>> C> experience with this.
>>>> C>
>>>>
>>>
>>
>>
>
Author
14 Nov 2007 9:27 PM
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?

Show quoteHide quote
"Willy Denoyette [MVP]" <willy.denoye***@telenet.be> wrote in message
news:eMxTENwJIHA.536@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" <cmm@nospam.com> wrote in message
> news:809EF727-4CB5-4DF6-9459-F5EB4B37F2D0@microsoft.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]" <willy.denoye***@telenet.be> wrote in message
>> news:uRdSvPtJIHA.5400@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" <cmm@nospam.com> wrote in message
>>> news:8EC5E46B-8521-45C5-936D-961122E5C44A@microsoft.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]" <nemt***@msn.com> wrote in message
>>>> news:3d9fba1a1a30e8c9f52e51e6db50@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
>>>>>
>>>>> C> I've been scouring the net for the last few days looking for a way
>>>>> to
>>>>> C> copy a locked file (create a shadow volume, expose it... that's it)
>>>>> C> from within my program. I'm aware of the kludgy vshadow.exe
>>>>> C> commandline tool, but what I really need is to be able to do it in
>>>>> C> managed code or via API's. I'm also aware of the VSS SDK so I don't
>>>>> C> need a pointer to them.... just wondering if anyone has had
>>>>> C> experience with this.
>>>>> C>
>>>>>
>>>>
>>>
>>>
>>
>
>
Author
14 Nov 2007 10:10 PM
Willy Denoyette [MVP]
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.

Show quoteHide quote
"CMM" <cmm@nospam.com> wrote in message
news:90A2D81A-41E3-433F-BB64-9865C55B58D3@microsoft.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]" <willy.denoye***@telenet.be> wrote in message
> news:eMxTENwJIHA.536@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" <cmm@nospam.com> wrote in message
>> news:809EF727-4CB5-4DF6-9459-F5EB4B37F2D0@microsoft.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]" <willy.denoye***@telenet.be> wrote in message
>>> news:uRdSvPtJIHA.5400@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" <cmm@nospam.com> wrote in message
>>>> news:8EC5E46B-8521-45C5-936D-961122E5C44A@microsoft.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]" <nemt***@msn.com> wrote in message
>>>>> news:3d9fba1a1a30e8c9f52e51e6db50@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
>>>>>>
>>>>>> C> I've been scouring the net for the last few days looking for a way
>>>>>> to
>>>>>> C> copy a locked file (create a shadow volume, expose it... that's
>>>>>> it)
>>>>>> C> from within my program. I'm aware of the kludgy vshadow.exe
>>>>>> C> commandline tool, but what I really need is to be able to do it in
>>>>>> C> managed code or via API's. I'm also aware of the VSS SDK so I
>>>>>> don't
>>>>>> C> need a pointer to them.... just wondering if anyone has had
>>>>>> C> experience with this.
>>>>>> C>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>
Author
15 Nov 2007 12:41 AM
CMM
Thank you. That was my question and the title of my post. I think even a
(simple) COM object (callable from .NET) that duplicates vshadow.exe would
have been useful. Looks like I have to rethink our strategy.

Show quoteHide quote
"Willy Denoyette [MVP]" <willy.denoye***@telenet.be> wrote in message
news:esvIcswJIHA.2064@TK2MSFTNGP06.phx.gbl...
> 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" <cmm@nospam.com> wrote in message
> news:90A2D81A-41E3-433F-BB64-9865C55B58D3@microsoft.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]" <willy.denoye***@telenet.be> wrote in message
>> news:eMxTENwJIHA.536@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" <cmm@nospam.com> wrote in message
>>> news:809EF727-4CB5-4DF6-9459-F5EB4B37F2D0@microsoft.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]" <willy.denoye***@telenet.be> wrote in message
>>>> news:uRdSvPtJIHA.5400@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" <cmm@nospam.com> wrote in message
>>>>> news:8EC5E46B-8521-45C5-936D-961122E5C44A@microsoft.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]" <nemt***@msn.com> wrote in message
>>>>>> news:3d9fba1a1a30e8c9f52e51e6db50@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
>>>>>>>
>>>>>>> C> I've been scouring the net for the last few days looking for a
>>>>>>> way to
>>>>>>> C> copy a locked file (create a shadow volume, expose it... that's
>>>>>>> it)
>>>>>>> C> from within my program. I'm aware of the kludgy vshadow.exe
>>>>>>> C> commandline tool, but what I really need is to be able to do it
>>>>>>> in
>>>>>>> C> managed code or via API's. I'm also aware of the VSS SDK so I
>>>>>>> don't
>>>>>>> C> need a pointer to them.... just wondering if anyone has had
>>>>>>> C> experience with this.
>>>>>>> C>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
>
Author
14 Nov 2007 1:54 PM
Willy Denoyette [MVP]
"CMM" <cmm@nospam.com> wrote in message
news:196DED00-295B-40D9-BA29-93ED8F6E9B4F@microsoft.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.