Solved

Shadow open a file

Posted on 2014-12-12
4
73 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 75

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 75

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

867 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

12 Experts available now in Live!

Get 1:1 Help Now