Mimic File.Move if the destination already exists

前端 未结 5 1816
小鲜肉
小鲜肉 2020-12-20 17:48

From the documentation of File.Move:

Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an IOEx

5条回答
  •  生来不讨喜
    2020-12-20 17:59

    The correct way to do it would be to call

    File.Replace(source, destination, copy)
    

    That does the trick for me

提交回复
热议问题