
Anonymous
Thanks, it's going to my code now, but I got different issue..
I am getting an error when trying copy from 1 library to other:
here is my code
SPSite siteCollection = new SPSite("http://test/sites/mysite/");
using (SPWeb oWebsite = siteCollection.OpenWeb())
{
SPFileCollection collFiles =
oWebsite.GetFolder("source").Files;
for (int intIndex = 0; intIndex < collFiles.Count; intIndex++)
{
collFiles[intIndex].CopyTo("http://test/sites/mysite/main/dest/" + collFiles[intIndex].Name);
}
}
This line of code :
collFiles[intIndex].CopyTo("http://test/sites/mysite/main/dest/" + collFiles[intIndex].Name);
collFiles[intIndex].Name returning the correct document name that i need to copy to dest library on http://test/sites/mysite/main
error I am getting
System.ArgumentException was unhandled by user code
Message=Value does not fall within the expected range.
Source=Microsoft.SharePoint
StackTrace:
at Microsoft.SharePoint.SPWeb.GetWebRelativeUrlFromUrl(String strUrl, Boolean includeQueryString, Boolean canonicalizeUrl)
at Microsoft.SharePoint.SPFile.MoveCopyInternal(String strNewUrl, Int32 grf, Boolean requireWebFilePermission)
at Microsoft.SharePoint.SPFile.CopyTo(String strNewUrl)
Can you please help me to resolve it?