It could be that the file you are trying to move has been locked by another process or another file has a handle on it. Thus, when you move it, it throws the exception. If you want to see which process is currently accessing it, then there is a tool, called Process Monitor, which will tell you which program is accessing it. You can get it from
http://www.microsoft.com/technet/sysinternals/utilities/ProcessExplorer.mspxAs a side note, was it intentional that it only moves the file if the destination file already exists, as the function at the moment copies the file, thus not causing any error, if the destination file does not exist, and only moves if the destination file does exist?