ADO.NET Provider for Microsoft SharePoint

Build 25.0.9539

DownloadDocument

Downloads a document from a SharePoint document library. Allows users to obtain offline copies or process documents externally. The RemoteFile can be either relative to the library or the full URL of the file.

Stored Procedure-Specific Information

Examples follow.

To download a file to a local path:

EXEC DownloadDocument
  File = 'C:/Users/User/Desktop/DownloadedFile.txt',
  Library = 'Shared Documents',
  RemoteFile = '/newFolder/FileToDownload.txt';

To download with a full URL, specify the complete URL for the remote file:

EXEC DownloadDocument
  File = 'C:/Users/User/Desktop/DownloadedFile.txt',
  Library = 'Shared Documents',
  RemoteFile = 'https://mysite.sharepoint.com/Shared Documents/newFolder/FileToDownload.txt';

To download file content as base64-encoded data instead of saving to disk:

EXEC DownloadDocument
  File = '',
  Library = 'Shared Documents',
  RemoteFile = 'test/qbxls.txt';
Note: When neither File nor FileStream is specified, content is pushed to the FileData output.

To download file content without encoding:

EXEC DownloadDocument
  File = '',
  Library = 'Shared Documents',
  RemoteFile = 'test/qbxls.txt',
  Encoding = 'NONE';

Input

Name Type Required Accepts Output Streams Description
File String False False The local file path where the downloaded document will be saved, including the filename. For example, 'C:/Users/User/Desktop/DownloadedFile.txt'.
Library String False False The name of the document library on the SharePoint server from which the file will be downloaded. For example, 'Shared Documents'.
RemoteFile String True False The file’s relative path within the library or its full SharePoint URL. Determines the exact file to be retrieved.
Encoding String False False Specifies the character encoding format for the downloaded data. Determines how the data is read and processed.

The allowed values are NONE, BASE64.

The default value is BASE64.

FileStream String False True The output stream to which the downloaded document will be written. Used if File is not provided.
ReadTimeout String False False The maximum number of seconds allowed for the download operation. If exceeded, the operation fails, unlike Timeout, which only triggers if the download stalls.

Result Set Columns

Name Type Description
Success Boolean Indicates whether the document download operation was successful. Returns 'true' for success and 'false' for failure.
FileData String Contains the downloaded file content as binary data. Only returned if neither File nor FileStream is specified.

Copyright (c) 2026 CData Software, Inc. - All rights reserved.
Build 25.0.9539