Hello, I have a text file that contains about 1000 lines which each have a syntax like this:
keyname=value
Now I am searching for an efficient/fast method to get the value that is associated with the keyname.
It has to be quick because I want to read all the values of the keynames at once and store it in a list so I can use them afterwards.
I currently use the WinAPI function "GetPrivateProfileString" for this because its moreless exactly what I want.
But I guess this is only used for (small) initialization files and probably rather slow (compared to other search methods), I think its even stated so in MSDN.
I could also copy the whole file content in the memory but I still would need to store each value in a list and I am unsure how to do this (or rather what the best solution is).
I hope you can help me with this, preferably with example code so I know how to use it properly ;)
1.) Read the entire file by...
2.) 1 line at a time...
3.) if you need that lines value push it otherwise ignore it...
4.) Continue this until end of file
I'm not sure what your question is then, it seemed like you were steering away from reading in the entire file. I was merely suggesting that you didn't need to 'run away'. (Unless for some reason your file access happens synchronously after load and continually) I deal with all kinds of file types on a regular basis and I've never had to use an "efficient" file processing technique as of yet, I will say that everything that hits a DB or file happens in worker threads and not in the main though. In the real world 1000 lines of text is nothing, so I wouldn't do premature optimization, I would make it easily maintainable and readable.