Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Copy open files?

Reply
 
Old 04-08-2008   #1 (permalink)
jim


 
 

Copy open files?

Is there a way (using VB.Net or C#) to copy open or locked files?

Thanks!

jim



My System SpecsSystem Spec
Old 04-08-2008   #2 (permalink)
kimiraikkonen


 
 

Re: Copy open files?

On Apr 8, 6:20 pm, "jim" <j...@xxxxxx> wrote:
Quote:

> Is there a way (using VB.Net or C#) to copy open or locked files?
>
> Thanks!
>
> jim
Look at this:
http://www.java2s.com/Code/VB/File-D...nlockafile.htm
My System SpecsSystem Spec
Old 04-08-2008   #3 (permalink)
Ignacio Machin ( .NET/ C# MVP )


 
 

Re: Copy open files?

On Apr 8, 11:20*am, "jim" <j...@xxxxxx> wrote:
Quote:

> Is there a way (using VB.Net or C#) to copy open or locked files?
>
> Thanks!
>
> jim
Hi,

No, if the file is locked by another process you cannot access it
My System SpecsSystem Spec
Old 04-08-2008   #4 (permalink)
Ignacio Machin ( .NET/ C# MVP )


 
 

Re: Copy open files?

On Apr 8, 12:45*pm, kimiraikkonen <kimiraikkone...@xxxxxx> wrote:
Quote:

> On Apr 8, 6:20 pm, "jim" <j...@xxxxxx> wrote:
>
Quote:

> > Is there a way (using VB.Net or C#) to copy open or locked files?
>
Quote:

> > Thanks!
>
Quote:

> > jim
>
> Look at this:http://www.java2s.com/Code/VB/File-D...nlockafile.htm
That shows how to lock/unlock a file, not how to read an already
locked file (most probably locked in another process)
My System SpecsSystem Spec
Old 04-08-2008   #5 (permalink)
Patrice


 
 

Re: Copy open files?

AFAIK no (except perhaps using a very low level API (I'm thinking about
backup specific APIs)).

You may want to elaborate on what you are trying to do but it looks like
something unusual...


"jim" <jim@xxxxxx> a écrit dans le message de news:
J2MKj.3941$DY1.2394@xxxxxx
Quote:

> Is there a way (using VB.Net or C#) to copy open or locked files?
>
> Thanks!
>
> jim
>

My System SpecsSystem Spec
Old 04-08-2008   #6 (permalink)
kimiraikkonen


 
 

Re: Copy open files?

On Apr 8, 8:43 pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@xxxxxx> wrote:
Quote:

> On Apr 8, 12:45 pm, kimiraikkonen <kimiraikkone...@xxxxxx> wrote:
>
Quote:

> > On Apr 8, 6:20 pm, "jim" <j...@xxxxxx> wrote:
>
Quote:
Quote:

> > > Is there a way (using VB.Net or C#) to copy open or locked files?
>
Quote:
Quote:

> > > Thanks!
>
Quote:
Quote:

> > > jim
>>
> That shows how to lock/unlock a file, not how to read an already
> locked file (most probably locked in another process)
Yes, i just wanted to point out that he could unlock the file using
the code then he could copy it.

(PS: The thread is a cross-post)
My System SpecsSystem Spec
Old 04-08-2008   #7 (permalink)
Willy Denoyette [MVP]


 
 

Re: Copy open files?

"kimiraikkonen" <kimiraikkonen85@xxxxxx> wrote in message
news:a64fa0bc-2ba5-4794-9a3d-727a6e82e61a@xxxxxx
Quote:

> On Apr 8, 8:43 pm, "Ignacio Machin ( .NET/ C# MVP )"
> <ignacio.mac...@xxxxxx> wrote:
Quote:

>> On Apr 8, 12:45 pm, kimiraikkonen <kimiraikkone...@xxxxxx> wrote:
>>
Quote:

>> > On Apr 8, 6:20 pm, "jim" <j...@xxxxxx> wrote:
>>
Quote:

>> > > Is there a way (using VB.Net or C#) to copy open or locked files?
>>
Quote:

>> > > Thanks!
>>
Quote:

>> > > jim
>>>>
>> That shows how to lock/unlock a file, not how to read an already
>> locked file (most probably locked in another process)
>
> Yes, i just wanted to point out that he could unlock the file using
> the code then he could copy it.
>
No you can't "unlock" a file "locked" by another process. Where "locked"
means opened exclusively, that is, non shared.
You can only use the "shadow copy services " to copy such file(s). The
shadow copy services API's aren't covered by the framework however.


Willy.

My System SpecsSystem Spec
Old 04-08-2008   #8 (permalink)
Peter Bromberg [C# MVP]


 
 

RE: Copy open files?

The Volume Shadow Copy service supports backing up locked files. There is an
API for this, which I have used via a batch file with script to backup the
Registry, but that's about as much as I can tell you.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net


"jim" wrote:
Quote:

> Is there a way (using VB.Net or C#) to copy open or locked files?
>
> Thanks!
>
> jim
>
>
>
My System SpecsSystem Spec
Old 04-08-2008   #9 (permalink)
kimiraikkonen


 
 

Re: Copy open files?

On Apr 8, 10:08 pm, "Willy Denoyette [MVP]"
<willy.denoye...@xxxxxx> wrote:
Quote:

> "kimiraikkonen" <kimiraikkone...@xxxxxx> wrote in message
>
> news:a64fa0bc-2ba5-4794-9a3d-727a6e82e61a@xxxxxx
>
>
>
Quote:

> > On Apr 8, 8:43 pm, "Ignacio Machin ( .NET/ C# MVP )"
> > <ignacio.mac...@xxxxxx> wrote:
Quote:

> >> On Apr 8, 12:45 pm, kimiraikkonen <kimiraikkone...@xxxxxx> wrote:
>
Quote:
Quote:

> >> > On Apr 8, 6:20 pm, "jim" <j...@xxxxxx> wrote:
>
Quote:
Quote:

> >> > > Is there a way (using VB.Net or C#) to copy open or locked files?
>
Quote:
Quote:

> >> > > Thanks!
>
Quote:
Quote:

> >> > > jim
>
Quote:
Quote:
>
Quote:
Quote:

> >> That shows how to lock/unlock a file, not how to read an already
> >> locked file (most probably locked in another process)
>
Quote:

> > Yes, i just wanted to point out that he could unlock the file using
> > the code then he could copy it.
>
> No you can't "unlock" a file "locked" by another process. Where "locked"
> means opened exclusively, that is, non shared.
> You can only use the "shadow copy services " to copy such file(s). The
> shadow copy services API's aren't covered by the framework however.
>
> Willy.
Willy,
The link i've posted claims that it locks and unlocks and updates the
same file under same application (under developer's application, even
can't get it worked such article). However there are some 3rd party
applications such as "Unlocker" which can unlock files locked by "any"
process . So that's another point of interest.

Plus it would be good to get a complete working code that locks and
unlocks and stores same file using FileStream class. The sample link
i've posted is not a well-explained one.

Thanks
My System SpecsSystem Spec
Old 04-08-2008   #10 (permalink)
Ignacio Machin ( .NET/ C# MVP )


 
 

Re: Copy open files?

On Apr 8, 2:30*pm, kimiraikkonen <kimiraikkone...@xxxxxx> wrote:
Quote:

> On Apr 8, 8:43 pm, "Ignacio Machin ( .NET/ C# MVP )"
>
> <ignacio.mac...@xxxxxx> wrote:
Quote:

> > On Apr 8, 12:45 pm, kimiraikkonen <kimiraikkone...@xxxxxx> wrote:
>
Quote:
Quote:

> > > On Apr 8, 6:20 pm, "jim" <j...@xxxxxx> wrote:
>
Quote:
Quote:

> > > > Is there a way (using VB.Net or C#) to copy open or locked files?
>
Quote:
Quote:

> > > > Thanks!
>
Quote:
Quote:

> > > > jim
>>
Quote:

> > That shows how to lock/unlock a file, not how to read an already
> > locked file (most probably locked in another process)
>
> Yes, i just wanted to point out that he could unlock the file using
> the code then he could copy it.
>
> (PS: The thread is a *cross-post)
Hi,

You can only unlock a file that you previously locked . Not only that,
but you must also use the same reference.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Urgent!! Can't copy/move or open files in Maxtor external drive. Vista file management
copy-item changing files attributes on network copy failures PowerShell
vista can't copy large files? another XP file-copy bug? Vista General
Can't copy media files into media library if WMP11 is open. Vista music pictures video
Can't copy media files into monitored folders while WMP11 is open. Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46