A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Searching for a string in a File
Let's you find the first occurance of a string within a file.
On Sunday, April 25th 2004 at 12:46 PM
By Sean Eshbaugh (View Profile)
(Rated 4.3 with 23 votes)
I started working on a project that was to replace the often times buggy and slow (and in my opinion just plain bad) Find Files/Folders function that comes with Windows (windows key + 'F'). In Windows XP the searching utility in the OS seems to be severly lacking in functionality. In previous versions of Windows I used i didn't find there to be too many problems.
Just a note, I know the return value is unsigned and in all the error cases I returned -1, remember, -1 is the same as 0xFFFFFFFF in a 32-bit number. Since i sincerly doubt you will ever come across a single file that is over 4GB this should never be a problem. If you should need to search a file that is over 4GB then I suggest replacing "unsigned long" with "unsigned __int64" if your compiler supports it. If you do need to do that then I doubt even more your hard drive can even hold a file that is 2^64 bytes in size so returning -1 (a REALLY big number for 64-bit numbers) will do nicely.
The above code is probably not the most effecient way of doing this, but it works, and it works fast. If i get the time I might try and make this as fast as possible, but unless this becomes the bottleneck of a program I'm working on that might not be for a while.
|Digg It! Del.icio.us Reddit StumbleIt Newsvine Furl BlinkList|
Rate this tutorial
There are no related tutorials.
Related Source Code
There is no related source code.
C++ Job Search
From the creators of Geekpedia, a revolutionary new coupon website!
BargainEZ has coupons codes, printable coupons, bargains and it is the leading source of Passbook coupons for iPhone and iPod touch devices.