Results 1 to 6 of 6

Thread: How to do this?

  1. #1

    Thread Starter
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200

    How to do this?

    Is it possible and how...

    Is it possible to search through a file without having to load it into RAM. What I an asking is this. If i know the format of a file, say text format. And I want to search through it for a string. if it contains the string i am looking for i will open it if not i will not waste my time with it.

    How can I search the contents of a file without actually opening it. Can I just read throught on the hard drive? Say i have a 30meg text file and i want to search it. So to save my computer from etting bogged down by trying to open it and read a line at a time would it be possible to just leave it on the hard disk and read it fro there?

    If so how?

    Thanks!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I suspect you can search a file without opening it first (not 100% sure).

  3. #3
    Lively Member
    Join Date
    Jan 2003
    Posts
    71
    Unless I'm nuts, when you "open" a file you get a handle to it from the operating system. without that handle you would have to know its exact physical location on the hard drive and somehow access each sector of the hard drive directly.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    and accessing these sectors needs C++ I think .

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    So to save my computer from etting bogged down by trying to open it and read a line at a time would it be possible to just leave it on the hard disk and read it fro there?
    No. Anything on the hard disk exists there. To read it, you have to bring it into memory either by opening the file, or mapping the file (which is really just 'opening a file' on a lower level)

    I don't think you should worry about 'bothering yourself' with opening a 30meg text file. You machine won't get bogged down opening the file, but rather the algorithm you use for searching.

    The OS will take care of buffering the memory pages... and usually runs with optimal performance. What I mean is depending on the RAM in a system, the OS will load as much of a file it deems necessary, and I don't think anyone without REAL hardcore knowledge of how the data is stored and organized on volumes will write anything better.

    You can use Win32 API's to get more control of how much you want to load in, but really I wouldn't bother, it gets damn complicated...

    Reading only part of a file:
    http://msdn.microsoft.com/library/de...e/readfile.asp

    Mapping part of a file:
    http://msdn.microsoft.com/library/en...le_mapping.asp
    Last edited by nemaroller; Jun 24th, 2003 at 02:50 PM.

  6. #6
    Addicted Member PeteD's Avatar
    Join Date
    Jun 2003
    Location
    Sydney
    Posts
    158
    You might find this interesting. Then again, you might not.

    http://archive.devx.com/dotnet/discu...leIOSyntax.asp

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