A while back I wrote a C# class that did fairly quick and easy encryption using the Rijndael method. It has two static functions that take a few parameters for the file to encrypt and at the end, I rename the newly created encrypted file to the name of the original file. The problem with this though is that the way I do it renames the file by first calling File.Replace() and then calling File.Delete() which deletes the temporary file that’s being created. On a large file, this can take a really long time to do. If this needs to happen to 30 files, it’s going to be very noticeable that there is a delay every time this needs to happen.
The solution is the use FileInfo.MoveTo() function which is much faster than File.Replace(). Make sure that the file name doesn’t already exist in the directory though.
Subscribe to
Posts [Atom]