I am moving files from one folder to another. If I try to move the entire folder to the folder within that particular folder I cannot do that. But if I move it outside it works fine. How can I move my folder to the folder within that folder?
this gives error
if (System.IO.Directory.Exists(PhysicalPath))
{
string sourcePath = "c:\\copypath\\";
string targetPath = "c:\\copypath\\abc\\";
System.IO.Directory.Move(sourcePath, targetPath);
}
this works fine
if (System.IO.Directory.Exists(PhysicalPath))
{
string sourcePath = "c:\\copypath\\";
string targetPath = "c:\\abc\\";
System.IO.Directory.Move(sourcePath, targetPath);
}
Trying to “c:\copypath\” into “c:\copypath\abc\” won’t work because it doesn’t make sense.
If you move the copypath folder then it won’t exist anymore, so how will the target folder (which is a subfolder) of it exist?
You could move all of the child files of “c:\copypath\” into “c:\copypath\abc\” instead, which wouldn’t cause a problem (again assuming you don’t try to copy abc into itself).