Solved

Shadow open a file

Posted on 2014-12-12
4
72 Views
Last Modified: 2015-01-03
I'm trying to backup a file to a web-service which I'm trying to upload segments, I've managed to get it working however I've now got a problem where the files are in use so I want to be able to create a shadow copy of the file and then open the file as a stream read and the read segments of the files.

What I have is now a problem as I have no idea how to create a shadow copy of a file and open a read stream to it. Im sure in .net 4 there is a method to shadow copy a file, but cannot find any documentation to it.

Any ideas?
0
Comment
Question by:tonelm54
  • 2
  • 2
4 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40497663
The only time I've ever heard of "shado copy" pertains to .NET assemblies. Why do you think you need shado copy here?
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40498264
@kaufmed

Shadow copy is also a feature of Windows that enables you to copy a file even while it is in use. It is a low level feature of Windows that is used for instance by backup software.


@tonelm54

Im sure in .net 4 there is a method to shadow copy a file, but cannot find any documentation to it.

I would have said the same thing, but there are still a few thins in Windows that do not seem to be covered by .NET.

I am in .NET 4.5.5, and still nothing in the documentation about shadow copy. So I think you fell on one of these holes where you still have to use the system API. If you're up to it, the documentation starts in Volume Shadow Copy API Reference.

If it is only one file, I would suggest to simply wait for the file to be available and make a regular copy. A user would not like to wait to get the file, but a web service might not mind too much.

If you need to process multiples files in one batch, then you could do what we do here. Use a commercial backup program to perform the backup, and copy the file generated by that backup program to your service. You will gain the advantage that commercial programs already bundles all the tools you need to search through archives or restore files, something that you would have to build yourself for an in-house system.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40498276
@James

Ah. So it overrides file locking then? Because I know that if a program doesn't open a file with an exclusive lock, then you can still read it even if it's in use.

On a side note, there must be an EE goblin loose, stealing all of the Ws. I can't otherwise explain how I misspelled "shadow" twice    XD
0
 
LVL 40
ID: 40498312
I do mostly database work nowadays, so I haven't worked with files for a long while. But won't opening a file for writing automatically prevents reading by default?

As for the gremlins, I haven't been young for a long while either, so I might be out of touch about there current behavior, but in my times, they were usually in greater number around this time of the year. Simply improve the security in your brain by wearing a hat all the time, and you should be OK.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now