FileStream in C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • newkhan
    New Member
    • Oct 2007
    • 35

    FileStream in C#

    Hello,
    I am using FileStream mechanism in my project and I want to delete some lines from the .txt file. I am reading line by using the following code

    while(SR.ReadLi ne())
    {
    ...............
    ...............
    }

    Thanks.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    What? I am very glad to hear you are using a FileStream, but please ask a question when you post.

    Comment

    • newkhan
      New Member
      • Oct 2007
      • 35

      #3
      Hi,

      You can't understand my problem, actually my problem was that ////////////////// i m using file stream in my project for reading and writing data in .txt files and i want to delete some lines from text file/////////////////// that was my question and untill this time i found the Seek method to go to my my required lines that should be deleted but unable to delete lines from txt file.

      Hope now you will understand.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Read your file into a string[] of lines.
        Then remove the lines you dislike from the string[] and write them back?

        I'm not sure you can delete lines out of file in filestream mode, might have to use BinaryStream.

        Comment

        Working...