المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to search for a specific string in a file?



C# Programming
03-07-2010, 02:30 AM
Hi,
Let's say that I've a file and I would like to find a specific string's ******** inside it. It is logical to load my file into a byte array and then parse it into a string or a StringBuilder byte by byte, right? It is an easy issue if the file is small.

If the file is huge (like 400megabytes), it is not that easy. The application demands lots of RAM and it is annoying. I thought about copying the file into the byte array by 100 bytes, step by step. But this brings another problem, if the half of my string is inside the first 100 bytes, and the rest in the next 100 bytes; my application is not able to identify my string and therefore give its ******** to me.

How can I solve this, any ideas?

If there is anything unclear, feel free to ask.
Thanks.