This happens when srcDate & dstData (typo also) have the same timestamp. A quick fix: if (srcDate *>=* dstData)
If this piece of code to to warn the user that you can’t edit Plugins/orbbec.ini maybe throw; a better error ?
If not why can’t you just do: try { File.Copy(srcName, dstName, true); //always override } catch { }
if file of dstName existed, you use File.Copy() function, it will throw IOException. So the first time you run this script, it’s ok , because the file does not exist, and it creats the file, but when you run it again, you will get IOException, my solution is to put the File.Copy() function behind File.Delete() function.