Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The Add method of the SPFileCollection class creates a file in the collection based on the specified URL and on a byte array that contains the file.
Parameters
strUrl A string that specifies the URL for the file.
file A byte array containing the file.
Return Value
A Microsoft.SharePoint.SPFile object that represents the file.
Remarks
If a file of the same name already exists, the Add method throws an exception.
Example
The following code example uses the Add method to copy a file from a document library to the Shared Documents folder of every subsite within a specified site.
This example requires using directives (Imports in Visual Basic) for both the Microsoft.SharePoint and Microsoft.SharePoint.WebControls namespaces.
Requirements
Platforms: Microsoft Windows Server 2003
Security: Code Access Security