CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Posts
    46

    Seeking specified character within a file

    Hello,
    What's the best way to seek to a certain delimiter character or string within a file?
    I need to do this repeatedly, "jumping" from one occurance of the string to the next.
    I know these strings will be somewhere towards the end of the file. Do I have to read from the begining, line by line until I encounter these delims?

  2. #2
    Join Date
    Jul 2006
    Posts
    97

    Re: Seeking specified character within a file

    Hi!
    Well, IMO it's the only way, to read the whole file until you encounter the delimiter. Unless .NET already has some feature like this.
    Another way is, if you are using your own file format, store offsets at the beginning of the file, so you could read them and seek to needed position in file. This saves some time if the file is big.
    Using .NET 2.0

  3. #3
    Join Date
    Sep 2006
    Location
    Eastern, NC, USA
    Posts
    907

    Re: Seeking specified character within a file

    Are you constrained by the type of file that you are using? Could you have your data in an XML file? Then you can find tags w/ ease.

    Pete

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

Featured