Thunderbird keeps two kinds of files: regular Berkeley mbox-style files, plus some database files to accelerate things. If you go into your Thunderbird directory (on Windows, that would be \Documents and Settings\pca\Application Data\Thunderbird\Profiles\<whatever>.default\ImapMail\your.mail.server.com), you'll see all the 'msf' files. Those are cached from your imap server. The 'sbd' files are subdirectories.
Assuming you trust your data is safely on the imap server, you can safely delete any 'msf' file and Thunderbird will rescan your imap directory.
Now, for your locally stored mail (in the Mail folder rather than the ImapMail folder), you'll see both 'msf' files and files without any suffix. The without-suffix files are your locally stored mail, in Berkeley-mbox format. You can safely delete the 'msf' files and Thunderbird will recreate them.
Warnings: never monkey around with these files when Thunderbird is actually running. Also, when in doubt, make backups before deleting files.