?
Solved

Shadow open a file

Posted on 2014-12-12
4
Medium Priority
?
80 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 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