|
-
Apr 29th, 2003, 11:37 PM
#1
process cannot access file... (Resolved)
I'm trying to make a program that reads the IIS log files and parses it (takes away the code red virus requests)
Everything works fine when I open a log from yesurday on, but with today's log I get this error:
The process cannot access the file "C:\WINDOWS\system32\Logfiles\W3SVC1\in030430.log" because it is being used by another process.
This is how I open the log file
VB Code:
' FileName is set to one of the files in that dir...
Dim fs As New FileStream(Path.Combine("C:\WINDOWS\system32\Logfiles\W3SVC1", FileName), FileMode.Open)
Dim sr As New StreamReader(fs)
So, how can I read the log file ?
Last edited by CVMichael; May 3rd, 2003 at 03:14 AM.
-
Apr 30th, 2003, 12:04 AM
#2
Frenzied Member
Try this, not sure it work
VB Code:
Dim fs As New FileStream(Path.Combine("C:\WINDOWS\system32\Logfiles\W3SVC1", FileName), FileMode.Open, FileAccess.Read, FileShare.Read)
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 30th, 2003, 12:08 AM
#3
-
May 2nd, 2003, 11:44 PM
#4
so... ammm.... anyone ???
-
May 3rd, 2003, 12:21 AM
#5
Frenzied Member
change it in this way:
VB Code:
Dim fs As New FileStream(Path.Combine("C:\WINDOWS\system32\Logfiles\W3SVC1", FileName), FileMode.Open, FileAccess.Read, FileShare.[b]ReadWrite[/b])
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
May 3rd, 2003, 03:13 AM
#6
I did not think it would make a difference, but it did, and it works!
Thanks...
-
May 3rd, 2003, 05:07 AM
#7
Frenzied Member
FileShare Enumerations:
Inheritable: Makes the file handle inheritable by child processes. This is not directly supported by Win32.
None:Declines sharing of the current file. Any request to open the file (by this process or another process) will fail until the file is closed.
Read: Allows subsequent opening of the file for reading. If this flag is not specified, any request to open the file for reading (by this process or another process) will fail until the file is closed. However, if this flag is specified additional permissions might still be needed to access the file.
ReadWrite: Allows subsequent opening of the file for reading or writing. If this flag is not specified, any request to open the file for writing or reading (by this process or another process) will fail until the file is closed. However, if this flag is specified additional permissions might still be needed to access the file.
Write: Allows subsequent opening of the file for writing. If this flag is not specified, any request to open the file for writing (by this process or another process) will fail until the file is closed. However, if this flag is specified additional permissions might still be needed to access the file.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|