I am current coding a custom web service for a Sharepoint 2010 site. This code is designed to copy the contents of one folder to another on sharepoint.
Currently, my code uses 'SPSite(SourceURL).openWeb()' to get access to an SPWeb object for the site. However, my code crashes and gives me the following error
The Web application at 'SourceURL' could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
In my code, SourceURL is the URL of the main site formatted as "https://sitename.com".
Thanks for any help,
Scott
EDIT: Here is the method that causes the error:
public void CopyFolderContents(String sourceURL, String folderURL, String destinationURL)
{
using (SPWeb oWebsite = new SPSite(sourceURL).OpenWeb())
{
SPFolder oFolder = oWebsite.GetFolder(folderURL);
//Create a list of all files (not folders) on the current level
SPFileCollection collFile = oFolder.Files;
//Copy all files on the current level to the target URL
CopyToTarget(collFile, destinationURL);
//Create a list of all folders on the current level
SPFolderCollection collFolder = oFolder.SubFolders;
//Copy each of the folders and all of their contents
EnumerateFolders(collFolder, destinationURL);
}
}