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ë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.
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.