I've been looking for method of copying a file or folder from one document library to a number of other libraries with the same name in each subsite for a particular site collection. What needs to happen is when a folder or file is added on one site it needs to be copied to all other sites in the collection.
I've seen that the
SPFile class has a
CopyTo() function but most of the answers regarding copying files I have come across suggest using
byte fileBytes = item1.File.OpenBinary(); string destUrl = lib2.RootFolder.Url + "/" + item1.File.Name; SPFile destFile = lib2.RootFolder.Files.Add(destUrl, fileBytes, true);
Which is the correct method for copying a file or folder structure within a site collection?