Read Locked Files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leon

    Read Locked Files

    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
    // Leon
  • Willy Denoyette [MVP]

    #2
    Re: Read Locked Files

    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.

    "Leon" <Leon@discussio ns.microsoft.co m> wrote in message
    news:806FEFD9-AD01-4D66-AB9E-F36554B5E891@mi crosoft.com...[color=blue]
    > 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
    > // Leon[/color]


    Comment

    • Leon

      #3
      Re: Read Locked Files

      Isn't it even possible to copy such a file?

      "Willy Denoyette [MVP]" wrote:
      [color=blue]
      > 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.
      >
      > "Leon" <Leon@discussio ns.microsoft.co m> wrote in message
      > news:806FEFD9-AD01-4D66-AB9E-F36554B5E891@mi crosoft.com...[color=green]
      > > 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
      > > // Leon[/color]
      >
      >
      >[/color]

      Comment

      • C-Services Holland b.v.

        #4
        Re: Read Locked Files

        Leon wrote:
        [color=blue]
        > Isn't it even possible to copy such a file?
        >
        > "Willy Denoyette [MVP]" wrote:
        >
        >[color=green]
        >>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.
        >>[/color][/color]

        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
        C-Services Holland b.v.

        Comment

        • Patrice

          #5
          Re: Read Locked Files

          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@discussio ns.microsoft.co m> a écrit dans le message de
          news:806FEFD9-AD01-4D66-AB9E-F36554B5E891@mi crosoft.com...[color=blue]
          > I'm trying to read a locked log file with C# but i get an IOExeption[/color]
          telling[color=blue]
          > 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[/color]
          a[color=blue]
          > temp file and then read it?
          >
          > please show me some examples
          >
          > Cheers
          > // Leon[/color]


          Comment

          Working...