Downloads a document in byte array format.

Syntax

Visual Basic (declaration)
Public Function DownloadDocument( _ 
ByVal AuthenticationTicket as String, _ ByVal Path as String) as Byte()

C# (declaration)
public byte[] DownloadDocument( 
string AuthenticationTicket, string Path)

Parameters

AuthenticationTicket
    string infoRouter ticket
Path
    string A document path in the infoRouter to be downloaded.

Return Value

Returns the content of the document in a byte array.

Remarks

The caller must be the owner of the document or must have at least "Read" permissions on the document.
If this function returns zero (0) bytes then call the function "GetDownloadInfo" to get the error description.

minus gif Example

Visual Basic Example
Option Explicit On
Option Strict On

Module module_DownloadDocument
    Sub DownloadDocument(ByVal ServiceURL As String, ByVal AuthenticationTicket As String)

        'Input Variables
        Const IRDocPath As String = "/TestDomain/samples/SummerPlan.doc"
        Const DownloadPath As String = "c:\temp\"

        Dim IR_OBJ As InfoRouter.srv
        Try

            'Update the reference
            IR_OBJ = New InfoRouter.srv
            IR_OBJ.Url = ServiceURL

            Dim FileName As String = System.IO.Path.GetFileName(IRDocPath)
            'call downloaddocument method to get bytearray
            Dim buffer As Byte() = IR_OBJ.DownloadDocument(AuthenticationTicket, IRDocPath)
            If IsArray(buffer) Then
                Dim fs As System.IO.FileStream = New System.IO.FileStream(DownloadPath & FileName, System.IO.FileMode.Create, IO.FileAccess.Write)
                Dim bw As System.IO.BinaryWriter = New System.IO.BinaryWriter(fs)
                'write bytearray to the local path
                bw.Write(buffer)
                bw.Close()
                fs.Close()
                bw = Nothing
                fs = Nothing
                Console.WriteLine("The document has been downloaded")
            Else
                Dim xml_response As System.Xml.XmlNode = IR_OBJ.GetDownloadInfo(AuthenticationTicket, IRDocPath)
                If Not (xml_response.Attributes("success").Value.ToUpperInvariant() = "TRUE") Then
                    Console.WriteLine("Server Response :" & xml_response.Attributes("error").Value)
                End If
                xml_response = Nothing
            End If

        Catch EX As Exception
            Console.WriteLine("error:" & EX.Message)
        Finally
            IR_OBJ = Nothing
        End Try
    End Sub
End Module