Downloads a document in byte array format.


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)


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

Return Value

Returns the content of the document in a byte array.


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

            '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 = Nothing
                fs = Nothing
                Console.WriteLine("The document has been downloaded")
                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)
            IR_OBJ = Nothing
        End Try
    End Sub
End Module