public class SharePointClientDownloadData : IDisposable
Do not create an instance of the SharePointClientDownloadData class directly. Instead, get an instance of an object by using one of the following methods:
Calling the SharePointClient.GetDownloadStream method and using its return value.
Calling the SharePointClient.GetDownloadStreamAsync method, an when the SharePointClient.DownloadCompleted event occurs the download stream is ready to be used. The SharePointClientDownloadCompletedEventArgs.DestinationData property that is a member of the event data will contain the instance of the SharePointClientDownloadData class being used.
In either case, you can use the Stream property to access the stream containing the downloaded item data (buffer).
The ETag property contains the SharePoint ETag that identifies the version of the file. This is obtained directly from SharePoint and is not used by the SharePointClient class.
The SharePointClientDownloadData class implements the System.IDisposable interface. Follow the standard .NET dispose pattern when using the SharePointClientDownloadData class. For more information, refer to the System.IDisposable interface documentation in MSDN.
Note: Do not dispose of the object in the Stream property yourself. Instead, the object will be disposed of when you call dispose on the owner SharePointClientDownloadData class.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.SharePoint.Client;
public void SharePointClientDownloadStreamExample()
{
// 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:
spClient.Credentials = new NetworkCredential(USER_NAME, PASSWORD, DOMAIN);
// Get the stream to the SharePoint item
using (SharePointClientDownloadData data = spClient.GetDownloadStream(sourceDocumentUri))
{
// Use RasterCodecs to get its information
using (RasterCodecs codecs = new RasterCodecs())
{
using (CodecsImageInfo imageInfo = codecs.GetInformation(data.Stream, true))
{
// Show the image info
Console.WriteLine("URL: {0}", sourceDocumentUri);
Console.WriteLine("Pages: {0}", imageInfo.TotalPages);
Console.WriteLine("Size: {0} by {1} pixels", imageInfo.Width, imageInfo.Height);
Console.WriteLine("Resolution: {0} by {1} dpi", imageInfo.XResolution, imageInfo.YResolution);
Console.WriteLine("Bits/Pixel: {0}", imageInfo.BitsPerPixel);
}
}
}
}