Groups | Blog | Home
all groups > dotnet general > november 2004 >

dotnet general : Read Locked Files



Leon
11/22/2004 11:41:06 PM
I'm trying to read a locked log file with C# but i get an IOExeption telling
me that the file is in use by another process.

Is there a way to read the file?

the file is only 200k so if i cannot read it, is it possible to copy it to a
temp file and then read it?

please show me some examples

Cheers
Willy Denoyette [MVP]
11/23/2004 10:59:39 PM
Examples of something that isn't possible?
If the file is in use and opened for exclusive access you won't be able to
open the file.
Willy.

[quoted text, click to view]

Leon
11/23/2004 11:01:09 PM
Isn't it even possible to copy such a file?

[quoted text, click to view]
C-Services Holland b.v.
11/24/2004 3:04:09 PM
[quoted text, click to view]

Think about it. To be able to copy it you (well the OS) need to read it.
And that is what is impossible if a file is in use and it's locked.

--
Rinze van Huizen
Patrice
11/24/2004 3:21:17 PM
Do you open the file in read only mode ?
If not, give it a try.
If you do already then the file is likely locked exclusively making possible
to even read its content. You'll have then to wait for this file to be
closed...

Patrice

--

"Leon" <Leon@discussions.microsoft.com> a écrit dans le message de
news:806FEFD9-AD01-4D66-AB9E-F36554B5E891@microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button