Last post Oct 24, 2009 06:53 AM by dev_2580
Oct 24, 2009 05:56 AM|hemant.yadav|LINK
i am getting this error "Cannot create a file when that file already exists." when trying to execute the following code in c#...
i want to copy the contect of the "folder" to "folder1" than delete the existing folder when i executed and traced the code its created the folder but when move the file its throughing the exception that "Cannot create a file when that file already exists.\r\w"
please help me out.....
Oct 24, 2009 06:15 AM|dev_2580|LINK
The reason that this is error is thrown is that the System.IO.Directory.Move Actually creates the new directory for you, then moves the content and deletes the old folder. So you are creating the destination directory and the Move funciton is also trying
to and that is why it "already exists".
Simply take out these lines and it will work 100% :
Oct 24, 2009 06:41 AM|hemant.yadav|LINK
i got the solution its working for me thanks again.....
Oct 24, 2009 06:53 AM|dev_2580|LINK
Good to hear that it is working. When you have got an answer, please don't forget to mark a post as answer. This helps me organise which post are complete and which ones are not