Reading your post, the best bet for you I think, is get another computer, plug your harddrive in it, backup all data in your D: partition, unplug then plug it back to the original computer, use Windows setup cd to delete all partitions in it then reinstall.
I think the problem is originally dirty C: partition which can be solved by running chkdsk using Recovery Console from Windows setup cd, but since you had tried reformatting it, it's too late to do it right now.
Well, I still doubt that what's happening to you is related to Avast, but I will check on my Windows desktops to see if the similar issue comes up.