Results 1 to 7 of 7

Thread: process cannot access file... (Resolved)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    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:
    1. ' FileName is set to one of the files in that dir...
    2. Dim fs As New FileStream(Path.Combine("C:\WINDOWS\system32\Logfiles\W3SVC1", FileName), FileMode.Open)
    3. 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.

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Try this, not sure it work
    VB Code:
    1. 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

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    Nope.... same thing...

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    so... ammm.... anyone ???

  5. #5
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    change it in this way:
    VB Code:
    1. 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

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    I did not think it would make a difference, but it did, and it works!

    Thanks...

  7. #7
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    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
  •  



Click Here to Expand Forum to Full Width