EncryptFile throwing "Cannot close stream until all bytes are written."

Aug 13, 2008 at 10:21 PM
I changed the crypto service provider from DESCryptoServiceProvider to RijndaelManaged and changed the padding correction code for ByteTotal to 16 ( from 8)

Everything else is unchanged.

Now when I try uploading files some of them upload fine while others fail with the above error.

I've narrowed it down to JPEG and text files work and word documents fail with the above error.

Looks like word seems to be always padding itself to make the total file size be a multiple of 16.

I'm stumped and would appreciate any help