Uploading a File to a SharePoint Site from a Local Folder
This programming task shows how to upload a file to a folder on a SharePoint site from a local folder. The task uses the EnsureParentFolder method to ensure that the destination folder exists.
Create a Web application in Visual Studio .NET as described in Creating a Web Application on a SharePoint Site, adding a FormDigest control and a page directive for the Microsoft.SharePoint.WebControls namespace to the .aspx file, as follows:
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>Note You can obtain the PublicKeyToken value for the current Windows SharePoint Services deployment from the default.aspx file in the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LCID(1033 in English)\STS folder, or from information provided for the Microsoft.SharePoint assembly at Local_Drive:\WINDOWS|WINNT\assembly in Windows Explorer.
Add an HtmlInputFile control, a text box, and a button to the form on the .aspx page:
Create a Web application in Visual Studio .NET as described in Creating a Web Application on a SharePoint Site, adding a FormDigest control and a page directive for the Microsoft.SharePoint.WebControls namespace to the .aspx file, as follows:
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>Note You can obtain the PublicKeyToken value for the current Windows SharePoint Services deployment from the default.aspx file in the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LCID(1033 in English)\STS folder, or from information provided for the Microsoft.SharePoint assembly at Local_Drive:\WINDOWS|WINNT\assembly in Windows Explorer.
Add an HtmlInputFile control, a text box, and a button to the form on the .aspx page:
Comments
Post a Comment