Luis:
Your code sound fantastic but what happend if the CDX is corrupted, I believe he is unable to read the file so your code also will be unable to read the CDX file.
I believe will be a better Idea to save all the index file properties in a method or database an call that database or method everytime you need to rebuild the cdx.