Results 1 to 2 of 2

Thread: Transfering a file from a webservice to a cliënt. I need to know file name.

  1. #1

    Thread Starter
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    Transfering a file from a webservice to a cliënt. I need to know file name.

    Hi all,

    I am use this code to transfer a file from a webservice to the cli&#235;nt:

    Code:
        <WebMethod(EnableSession:=True)> _
        Public Function GetSignature() As Byte()
    
                Dim binReader As New IO.BinaryReader(IO.File.Open("C:\Bar.emf", IO.FileMode.Open, IO.FileAccess.Read))
                binReader.BaseStream.Position = 0
                Dim binFile As Byte() = binReader.ReadBytes(Convert.ToInt32(binReader.BaseStream.Length))
                binReader.Close()
    
                Return binFile
        End Function
    Code:
    Dim file As Byte() = proxy.GetSignature()
    
                Dim binWriter As New IO.BinaryWriter(New System.IO.FileStream("FILE NAME HERE??", System.IO.FileMode.Create))
                binWriter.Write(file)
                binWriter.Close()
    Is the filename stored somewhere in the byte()? If so, how can I get it? Or do I have to send the filename seperately as String.

    Thnx in advance.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Transfering a file from a webservice to a cliënt. I need to know file name.

    No, the file name is not stored in the byte() array. If you want to get the file name as well as the file contents, you need to modify your webservice method to return a DictionaryEntry (or create your own type. It can be a structure or class but must be serializable). You then can use the filename as the key and the file byte() as the value for the dictionaryEntry object.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width