Provides client access support to Microsoft SharePoint servers.
public class SharePointClient
Public Class SharePointClient
public ref class SharePointClient
The SharePointClient class provides client access support for Microsoft SharePoint Servers. This class allows you to:
Download items from a SharePoint server.
Download a file to a disk using DownloadFile or DownloadFileAsync.
Get a stream containing data for download using GetDownloadStream or GetDownloadStreamAsync.
Upload items to a SharePoint server.
Upload a disk file using UploadFile or UploadFileAsync.
Upload the data contained in a stream using UploadStream orUploadStreamAsync.
Set up credentials and (optional) proxy servers with the Credentials and Proxy properties.
This example will connect to a Microsoft SharePoint Server to download an image file. It will then invert the image before uploading it back to the Sharepoint Server.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.SharePoint.Client;
private static void SharePointClientExample()
{
// 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;
// Replace SHAREPOINT_DOCUMENT_NAME with a valid document on the folder above, for example
// MyDocument.tif
string documentName = SHAREPOINT_DOCUMENT_NAME;
// Build the full URL to the document are we going to download
UriBuilder builder = new UriBuilder(siteUri);
builder.Path = Path.Combine(builder.Path, folderName);
builder.Path = Path.Combine(builder.Path, documentName);
Uri sourceDocumentUri = builder.Uri;
SharePointClient spClient = new SharePointClient();
// Optional: Set the credentials:
if (USER_NAME != null)
{
spClient.Credentials = new NetworkCredential(USER_NAME, PASSWORD, DOMAIN);
}
// Optional: If you must use a Proxy server to connect to SharePoint, set it up:
if (PROXY_HOST != null)
{
WebProxy proxy = new WebProxy(PROXY_HOST, PROXY_PORT);
spClient.Proxy = proxy;
}
string tempFileName = Path.GetTempFileName();
try
{
// Download the SharePoint item to the temporary file
Console.WriteLine("Downloading {0}", sourceDocumentUri);
spClient.DownloadFile(sourceDocumentUri, tempFileName);
// Load the image
using (RasterCodecs codecs = new RasterCodecs())
{
using (RasterImage image = codecs.Load(tempFileName))
{
// Invert it
Console.WriteLine("Inverting");
new InvertCommand().Run(image);
// Save it back to the same file
Console.WriteLine("Saving back to disk");
codecs.Save(image, tempFileName, image.OriginalFormat, image.BitsPerPixel);
}
}
// Upload the file back with a new name (OriginalName_Inverted.ext)
string name = Path.GetFileNameWithoutExtension(documentName);
string ext = Path.GetExtension(documentName);
name = name + "_Inverted";
name = Path.ChangeExtension(name, ext);
// Get the destination path (destination folder + file name)
string destinationPath = Path.Combine(folderName, name);
Console.WriteLine("Uploading to {0}", destinationPath);
// Make sure to overwrite the file if it already exists
spClient.OverwriteExistingFiles = true;
spClient.UploadFile(tempFileName, siteUri, destinationPath);
}
finally
{
// Delete the temporary file
File.Delete(tempFileName);
}
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.SharePoint.Client
Private Shared Sub SharePointClientExample()
' Replace SHAREPOINT_SITE_URI with a valid URL to a SharePoint site, for example
' http://SiteCollection/MySite
Dim siteUri As New Uri(SHAREPOINT_SITE_URI)
' Replace SHAREPOINT_FOLDER_NAME with a valid folder on the site above, for example
' "Documents" or "Documents\Sub Documents"
Dim folderName As String = SHAREPOINT_FOLDER_NAME
' Replace SHAREPOINT_DOCUMENT_NAME with a valid document on the folder above, for example
' MyDocument.tif
Dim documentName As String = SHAREPOINT_DOCUMENT_NAME
' Build the full URL to the document are we going to download
Dim builder As New UriBuilder(siteUri)
builder.Path = Path.Combine(builder.Path, folderName)
builder.Path = Path.Combine(builder.Path, documentName)
Dim sourceDocumentUri As Uri = builder.Uri
Dim spClient As New SharePointClient()
' Optional: Set the credentials:
If Not IsNothing(USER_NAME) Then
spClient.Credentials = New NetworkCredential(USER_NAME, PASSWORD, DOMAIN)
End If
' Optional: If you must use a Proxy server to connect to SharePoint, set it up:
If Not IsNothing(PROXY_HOST) Then
Dim proxy As New WebProxy(PROXY_HOST, PROXY_PORT)
spClient.Proxy = proxy
End If
Dim tempFileName As String = Path.GetTempFileName()
Try
' Download the SharePoint item to the temporary file
Console.WriteLine("Downloading {0}", sourceDocumentUri)
spClient.DownloadFile(sourceDocumentUri, tempFileName)
' Load the image
Using codecs As New RasterCodecs()
Using image As RasterImage = codecs.Load(tempFileName)
' Invert it
Console.WriteLine("Inverting")
Dim cmd As New InvertCommand()
cmd.Run(image)
' Save it back to the same file
Console.WriteLine("Saving back to disk")
codecs.Save(image, tempFileName, image.OriginalFormat, image.BitsPerPixel)
End Using
End Using
' Upload the file back with a new name (OriginalName_Inverted.ext)
Dim name As String = Path.GetFileNameWithoutExtension(documentName)
Dim ext As String = Path.GetExtension(documentName)
name = name + "_Inverted"
name = Path.ChangeExtension(name, ext)
' Get the destination path (destination folder + file name)
Dim destinationPath As String = Path.Combine(folderName, name)
Console.WriteLine("Uploading to {0}", destinationPath)
' Make sure to overwrite the file if it already exists
spClient.OverwriteExistingFiles = True
spClient.UploadFile(tempFileName, siteUri, destinationPath)
Finally
' Delete the temporary file
File.Delete(tempFileName)
End Try
End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.