I see lots of threads on copying files from one document library to another, but i want to move or copy a complete document library from one site to another (within the same site collection).
Is this possible with .NET C# code?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, this is not possible – this is where specialized Backup solutions from third party vendors come in.
If you are talking about a simple document library it is of course not that hard:
Secondly you just have to iterate over all documents in the library and use use the
SPFolder.AddcommandSPFileCollection collFile = collFolder.Files;foreach(SPFile file in collFile)
destFolder.Files.Add(file.Name, file.OpenBinary());
The collFolder in this case is the original document libary. The destFolder is the new document library. You can get the doc libs as a folder by using
SPWeb.GetFolder(string doclibname).