|
-
Jun 23rd, 2003, 09:39 PM
#1
Thread Starter
Addicted Member
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!
-
Jun 23rd, 2003, 11:31 PM
#2
Sleep mode
I suspect you can search a file without opening it first (not 100% sure).
-
Jun 24th, 2003, 08:11 AM
#3
Lively Member
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.
-
Jun 24th, 2003, 02:04 PM
#4
Sleep mode
and accessing these sectors needs C++ I think .
-
Jun 24th, 2003, 02:42 PM
#5
I wonder how many charact
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.
-
Jun 24th, 2003, 08:01 PM
#6
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|