File Sharing Bug(?) in File.OpenText 
Author Message
 File Sharing Bug(?) in File.OpenText

I'm trying to read a text-based log file on a (Java-based) server machine.
The server keeps the file open to write log entries to it.

When I try to open the file (using File.OpenText, File.Open, or other
approaches) I get an error indicating that the file can't be opened because
it is being used by another process, even though I am only opening the file
for read.

I've even tried using the File.Open call so that I can set the sharing mode
to READ. That didn't work either.

I know it's possible, since I can open the same file using WordPad or
NotePad. What am I doing wrong?


posting here (I'm not sure I'll find it here).

Thanks!



Sun, 17 Apr 2005 00:01:51 GMT  
 File Sharing Bug(?) in File.OpenText
AFAIK, if the server process has the file opened exclusively then you won't be
able to open it, even for read-only.  The server would have to open the file in
a mode that would allow shared access, at least for reading.

--Bob


Quote:
> I'm trying to read a text-based log file on a (Java-based) server machine.
> The server keeps the file open to write log entries to it.

> When I try to open the file (using File.OpenText, File.Open, or other
> approaches) I get an error indicating that the file can't be opened because
> it is being used by another process, even though I am only opening the file
> for read.

> I've even tried using the File.Open call so that I can set the sharing mode
> to READ. That didn't work either.

> I know it's possible, since I can open the same file using WordPad or
> NotePad. What am I doing wrong?


> posting here (I'm not sure I'll find it here).

> Thanks!



Sun, 17 Apr 2005 00:16:22 GMT  
 File Sharing Bug(?) in File.OpenText
Tom,

Take a closer look at the fourth parameter of the Open method having
FileShare type.
You will most likely have to specify FileShare.Read or FileShare.ReadWrite
depending
on the purpose of opening the file.

--
Dmitriy Lapshin
X-Unity Unit Testing and Integration Environment
http://x-unity.miik.com.ua


Quote:
> I'm trying to read a text-based log file on a (Java-based) server machine.
> The server keeps the file open to write log entries to it.

> When I try to open the file (using File.OpenText, File.Open, or other
> approaches) I get an error indicating that the file can't be opened
because
> it is being used by another process, even though I am only opening the
file
> for read.

> I've even tried using the File.Open call so that I can set the sharing
mode
> to READ. That didn't work either.

> I know it's possible, since I can open the same file using WordPad or
> NotePad. What am I doing wrong?


> posting here (I'm not sure I'll find it here).

> Thanks!



Sun, 17 Apr 2005 00:16:42 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. File.OpenText problems, where is Acces mode ?

2. C6.0, file sharing bug?

3. Bug?? OpenText does not return the £ character

4. file sharing under DOS (share not necessarily loaded)

5. How to make a trace file shared?

6. Peer to Peer/P2P or File Sharing

7. how do I open a shared file

8. File.Copy doesn't work for Network Shares

9. Sharing source files between projects

10. File.Open sharing question

11. asynchronous file share for write access

12. File Sharing Violations

 

 
Powered by phpBB® Forum Software