Directory.Move() wierd behaviour

Hi All,

I am using Directory.Move() and am getting the following error “Cannot create a file when the file already exists”.

I am passing 2 params:

Param1 = "D:\\Integration\\Site\\Images\\Folder1"
Param1 = "D:\\Integration\\Site\\Images\\Folder2"

Then calling:


Directory.Move(Param1, Param2);

with the idea that folder 1 will end up in folder 2. Both folders are empty.

I guess I am doing something wrong but can’t see what.

I think I have found my answer Param2 should contain the folder you are trying to copy param1 to, so:


Param1 = "D:\\Integration\\Site\\Images\\Folder1"
Param2 = "D:\\Integration\\Site\\Images\\Folder2\\Folder1"

This is silly mistake you did here. The destination folder is created by Directory.Move(S1,D1).Delete D1 destination folder and try this solution . This will work.
Directory.move creates a new folder that you specify and copy all the content of folder in Destination one.
Do not create physical folder in D drive at path given-Param1 = “D:\Integration\Site\Images\Folder2”
Hope this help.