tags:

views:

250

answers:

3

hi

this is Ramesh

i have winforms, i trying to copy the file one location to another,if same file name is there i need to overwrite, but i got error like "Cannot create a file when that file already exists."

but my query is i want to overwite what should i do? but i'm trying File.copy and File.move method not in use same error come out.... i'm novice..in c#

advance wishes

+1  A: 

File.Copy(source,destination,true) will overwrite destination if permissions allow. See the docs.

Vinko Vrsalovic
+3  A: 

have you tried File.Copy(src, dest, true). This might help overwriting the existing file.

sdp07
A: 

Check the write permission is allowed for the folder contains the destination file.

Try the following:

System.IO.File.Copy(src, dst, true);

true if you want the existing file will be overwritten.

To change or set file permission click here

Himadri