Shrinking the File Length
Hi, I've got a file that I use for storing data as records, now adding records works fine, but what if I want to remove records and reclaim the unused space? Is there an easier way to do this other than rewriting the whole file? All the examples I've seen actually kill the file and rewrite all the data, this isn't a problem if the file is small, but thinking ahead it may cause a delay if the file is large.
[419 byte] By [
PsychUK] at [2007-12-23]
Yes I know, but I found using saved data structures alot better for alot of reasons, I dont get any runtime exceptions now, I originally used a database, and found it hung the application at startup due to the servers starting up, etc, but that's another discussion. I use List (Of T) now, does more or less exactly the same thing for what I want and doesnt need any external processes to keep it running.
If that's the case (flat files), you have to rewrite the whole file (Technically, I think you could rewrite the end of file location using some win32 APIs but I think it'd cause more problems than what it's worth).
Thanks SJ.
I was thinking that was the case, but I wasnt sure if there was a method somewhere I had overlooked, maybe I'll put a backup routine on another thread that doesnt save deleted records, anyways, its no big deal. Thanks again.