Uploads an item in a disk file to a SharePoint server folder.
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).
This method will upload the content of sourceFileName to SharePoint server. The location and name of the destination item in the server is determined as follows:
DestinationFileFullUrl = siteUri + destinationPath
For example, assume the SharePoint server contains a folder with the following name:
http://site/Shared Documents/
And you want the uploaded item with the name File.ext
into this folder. You can perform this using this code:
Uri siteUri = new Uri(@"http://site");
string destinationPath = @"Shared Documents/File.ext";
sharePointClientObject.UploadFile(sourceFileName, siteUri, destinationPath);
You can use the .NET System.IO.Path and System.UriBuilder classes to build the path and URI of the items. No that destinationPath is allowed to contain slashes (/) as in HTTP URI's or forward slashes (\) as in Windows paths or a mix of both.
This method will not return until the item is finished uploading to the server. If an error occurs, this method will throw an exception.
To upload a file asynchronously, use UploadFileAsync.
To upload the data in a stream to the server, use UploadStream or UploadStreamAsync.
To down an item from SharePoint, use DownloadFile, DownloadFileAsync, GetDownloadStream or GetDownloadStreamAsync.
This example will upload an image file to SharePoint.
Products |
Support |
Feedback: UploadFile Method - Leadtools.SharePoint.Client |
Introduction |
Help Version 19.0.2017.3.21
|