Hello, Markus!
File is locked both for reading and writing?
Did you try opening the file with, say notepad. Will it succeed?
--
With best regards, Vadym Stetsiak.
Blog: http://vadmyst.blogspot.com
You wrote on Tue, 16 Oct 2007 09:17:49 -0000:
ME> Hi Newsgroup,
ME> I have a problem that is not directly C#-related, but I'd like to
ME> solve it in C#.
ME> A data acquisition station generates heaps of data, which shall be
ME> transferred to a server. As the connection may be rather slow, I
ME> can't wait until the acquisition ends - and unfortunately I don't
ME> have access to the data acquisition source codes.
ME> Is there a way to transfer this data while it is being recorded? The
ME> acquisition program locks the files during acquiring and writing the
ME> data, so opening the files and transferring the data that is already
ME> there, probably won't work. But there are programs out there that
ME> can open (for reading) locked files. How are they doing it?
ME> I thought, maybe Volume Shadow Services might be a way, but I could
ME> not find any examples proving it.
ME> Any ideas?
ME> Regards
ME> Markus
Markus Erlacher - 16 Oct 2007 14:41 GMT
Hi Vadym,
Opening it with Notepad fails, drag-n-drop to make a copy fails also.
regards
Markus
> Hello, Markus!
>
[quoted text clipped - 4 lines]
> With best regards, Vadym Stetsiak.
> Blog:http://vadmyst.blogspot.com
Willy Denoyette [MVP] - 16 Oct 2007 16:59 GMT
> Hi Vadym,
>
> Opening it with Notepad fails, drag-n-drop to make a copy fails also.
Which means that the file is opened in *exclusive* mode, there is nothing
you can do about this, no other program can open such file simultaneously.
As you don't own the acquisition source code, VSS is not an option either.
Willy.
Markus Erlacher - 17 Oct 2007 12:36 GMT
Hi Willy,
thanks for the response. That's no good news for me, but probably in
terms of security the right thing for the operating system to do. But
thanks for the hint that even VSS is no option.
But one thing still confuses me: how do backup softwares handle these
files?
Markus
On 16 Okt., 17:59, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.be> wrote:
> > Opening it with Notepad fails, drag-n-drop to make a copy fails also.
>
[quoted text clipped - 3 lines]
>
> Willy.
Willy Denoyette [MVP] - 17 Oct 2007 16:20 GMT
> Hi Willy,
>
[quoted text clipped - 18 lines]
>>
>> Willy.
Basically 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.
Once you have the file handle, you can use it to perform backup operations
using the Backup API's like Kernel32 API "BackupRead".
Nothing of this all is wrapped by the Framework, you need to PInvoke. Also,
you need to run with the "SeBackupPrivilege "enabled for your process, (IMO)
something you don't want your user processes to run with.
Willy.