views:

39

answers:

0

I am using a CryptoStream for writing encrypted audio data to the file (underlying stream is FileStream). When I try to call CryptoStream.Close() over the full disk, I get an exception. I know that this is because CryptoStream.Close() invokes FlushFinalBlock() during disposing. As a result I get the corrupted data in my encrypted file and recieve error like "Incorrect padding" during decryption.

Is there any way to close a CryptoStream correctly without data loosing, when the disk becomes full? Maybe there is any possibility to reserve a space for the final block before I get an IOException that disk is full?