How to find the folder URL to use with SPFile.MoveTo(string)
The folder URL is in the RootFolder parameter that you see in the address bar when you are viewing the folder. This is counterintuitive to me, because the SPList.RootFolder object will give you exactly that, the root folder, whereas the RootFolder parameter gives you a site-relative URL of the current folder. So the example code in MSDN on SPFile.MoveTo seems to be incorrect. To successfully move files from the actual root folder of a list to another folder within that list, I took the RootFolder parameter and decoded the escaped characters, and concatenated the filename (SPFile.Name) to the folder URL. So it was something like files[i].MoveTo("/Corp/Depts/ThisDept/ThisFolder/" + files[i].Name); See the MSDN code example for the rest.
Posted on January 12, 2012, in .NET, SharePoint. Bookmark the permalink. Leave a Comment.
Leave a Comment
Comments (0)