I am using Winforms, and I am trying to copy a file from one location to another. If a file with the same name is already there, I want to overwrite it. But I get an error like "Cannot create a file when that file already exists."
I want to overwrite the file. What should I do?
I tried File.copy
instead of File.move
, but I got the same error.
Several users are reportedly getting the “Cannot create a file when that file already exists” error when trying to change the status of the Smart Card (SCardSVR) service from Disabled to a different state. The issue is reported to occur with multiple Windows versions including Windows 7, Windows 8.1 and Windows 10.
This error occurs at run time when the new file name, for example, one specified in a Name statement, is identical to a file name that already exists. Specify a new file name in the Name statement or delete the old file before specifying it in a Name statement.
This error simply means something is already running on the port number that you are planning on using (and that probably means the default website is already using a binding with port 80, and you are attempting to add another website or application with a binding to port 80).
To delete a symbolic link, treat it like any other directory or file. If you created a symbolic link using the command shown above, move to the root directory since it is "\Docs" and use the rmdir command. If you created a symbolic link (<SYMLINK>) of a file, to delete a symbolic link use the del command.
File.Copy(source,destination,true)
will overwrite destination if permissions allow. See the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With