tags:

views:

45

answers:

3

Can a file already in use be cloned in vb2005?

Is it possible to load a file into memory even if that file is already in use by another program?

+3  A: 

It should be possible, but only if the other application doesn't have the file open with a file share mode of None or "exclusive" Write (FileShare.None or FileShare.Write in .NET)

Here is a list of possible windows file sharing modes. It is for C++, but the same principles apply across the board since file sharing is an operating system level concept.

For .NET, the same principles apply. See the FileShare enumeration (although the discussion from the link above is more useful to understand what types of file locks are involved with the different types of file share modes)

Miky Dinescu
A: 

If the other program is .NET it depends how it opened the file. If it opened it with FileShare.None then you will be out of luck, otherwise it is possible.

RichardOD
A: 

When I can't open a file in notepad/ultra-edit because an application has locked the file, I can copy the locked file and the copy opens without any problem.

Maybe the same strategy can be used in c# code?

Kevin