I have a Sharepoint deployment with the following hierarchy :
Within the second archive site I have the following hierarchy within a document library DocLib : Folder1/Folder2/
I want to copy a SPFile instance from a document library within http://myserver.com:23456/ to the Folder2 within the archive site using the SPFile.CopyTo() command. This appears to be feasible based on the answer provided at this SO discussion.
If I attempt the copy operation using the following code snippet, I get an SPException that Folder2 cannot be found.
SPFile fileObj; SPFolder destFolder; //points to myserver.com:23456/Archive/DocLib/Folder1/Folder2 fileObj.CopyTo(destFolder.ServerRelativeUrl + "/" + fileObj.Name);
I have verified that Folder2 exists. I am curious to know if I am doing the right thing here.