first of all use code tags when you're inserting large parts of the code. the way it is here will strip people of any desire to help you.
there is a lot of commented code which is unnecesary here and I assume it confuses you as well.
for example:
you read the number of records here:
FS.ReadBuffer(FileSize, SizeOf(FileSize));
but you never write it.
so my advice is clean you code, work through it step by step and you will surely fix all your problems.
Bookmarks