UploadFile Method (original) (raw)

Summary

Uploads an item in a disk file to a SharePoint server folder.

Syntax

Parameters

sourceFileName
The file containing the item data to upload. This value cannot be null (Nothing in VB) and must contain the location of an existing file on disk.

siteUri
Full URL to the destination SharePoint site. This could be http://MySite or http://MySiteCollection/MySite. This value cannot be null (Nothing in VB).

destinationPath
Destination path (folder and file name) of the item to be created in the SharePoint server. See the remarks section for more information. This value cannot be null (Nothing in VB).

Example

This example will upload an image file to SharePoint.

using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Color; using Leadtools.SharePoint.Client; public void SharePointClientUploadFileExample() { string sourceFileName = LEAD_VARS.ImagesDir + @"\Ocr1.tif"; // Replace SHAREPOINT_SITE_URI with a valid URL to a SharePoint site, for example // http://SiteCollection/MySite Uri siteUri = new Uri(SHAREPOINT_SITE_URI); // Replace SHAREPOINT_FOLDER_NAME with a valid folder on the site above, for example // "Documents" or "Documents\Sub Documents" string folderName = SHAREPOINT_FOLDER_NAME; SharePointClient spClient = new SharePointClient(); spClient.OverwriteExistingFiles = true; // Optional: Set the credentials: spClient.Credentials = new NetworkCredential(USER_NAME, PASSWORD, DOMAIN); // Build the upload document full path (folder + file name) string destinationPath = Path.Combine(folderName, Path.GetFileName(sourceFileName)); // Upload the document spClient.UploadFile(sourceFileName, siteUri, destinationPath); } static class LEAD_VARS { public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; }