locked
Read from a locked txt file RRS feed

  • Question

  • Hi,

    I´m trying to read a txt file using streamreader, but the file is locked by another process. The problem is that, since this is a log file I can´t stop de other process that is using it.

    Any ideias?

    Tks
    Thursday, November 29, 2007 11:24 PM

Answers

  • It depends on how the other program is sharing the file.  If the other program has opened the file with an exclusive lock, then you won't be able to read it.  If the other program has opened the file and shares the file for reading, then you should be able to read the file.

     

    Make sure that when you open the file, you specify the proper FileAccess and FileShare modes. 

     

    Chris

     

     

     

    Friday, November 30, 2007 3:41 PM