I am trying to move the directory from one location to another location on the same drive. I am getting \"Cannot create a file when that file already exists
You don't need to create Directory first, it will throw IO Exception, if destination directory exists, Move method automatically creates it for you:
string sourcedirectory = @"F:\source";
string destinationdirectory = @"F:\destination";
if (Directory.Exists(sourcedirectory))
{
if (!Directory.Exists(destinationdirectory))
{
Directory.Move(sourcedirectory, destinationdirectory);
}
}
More infomation of Directory.Move:
http://msdn.microsoft.com/en-us/library/system.io.directory.move.aspx