Content back up and Restore
-
Can i know how to take backup for content.I am sending my code also. I am writing code on web service. [WebMethod] public void downloadArcive(string SiteUrl, string ContentName) { SPSite site = new SPSite(SiteUrl); SPWeb web = site.OpenWeb(); SPFolder myFolder = web.GetFolder(ContentName); SPFileCollection myFiles = myFolder.Files; String backupLocation = "c:/Bin"; String backupfile = "http://ak-vpc/sites/governance"; UInt64 diskFreeSize = 0; UInt64 diskSize = 0; foreach (SPFile file in myFiles) { if (file.Length > 1) { for (int i = myFiles.Count - 1; i > -1; i--) { myFiles[i].MoveTo(backupLocation, true); //I am getting error.............. :zzz: } } } } i am getting error .Please help where i did mistake.
-
Can i know how to take backup for content.I am sending my code also. I am writing code on web service. [WebMethod] public void downloadArcive(string SiteUrl, string ContentName) { SPSite site = new SPSite(SiteUrl); SPWeb web = site.OpenWeb(); SPFolder myFolder = web.GetFolder(ContentName); SPFileCollection myFiles = myFolder.Files; String backupLocation = "c:/Bin"; String backupfile = "http://ak-vpc/sites/governance"; UInt64 diskFreeSize = 0; UInt64 diskSize = 0; foreach (SPFile file in myFiles) { if (file.Length > 1) { for (int i = myFiles.Count - 1; i > -1; i--) { myFiles[i].MoveTo(backupLocation, true); //I am getting error.............. :zzz: } } } } i am getting error .Please help where i did mistake.
Hi, Why are you using this technique for backup? There are several alternatives to perform a more solid and consistent backup of your content. Create a simple batch file on the server and use stsadm -o backup. As for your specific error, it's probably because the backuplocation is not a SharePoint library the Move operation expect a SharePoint library as operator. See the API documentation (here's an extract) The MoveTo method moves files to another location within the same site. This method returns an error if a file of the same name already exists at the new location. Hope this helps! Regards, Alain Lord MVP SharePoint Server SharePoint Quebec User Group Lead