添付データをバイト配列に入れて送信してみませんか?
Public Class SoapPackage
Public Property AttachmentName() As String
Get
Return m_AttachmentName
End Get
Set
m_AttachmentName = Value
End Set
End Property
Private m_AttachmentName As String
' put your file data in here
Public Property AttachmentData() As Byte()
Get
Return m_AttachmentData
End Get
Set
m_AttachmentData = Value
End Set
End Property
Private m_AttachmentData As Byte()
End Class
これらの行に沿ってファイルをバイト配列にストリーミングします(添付ファイルのストリームを開き、この関数に渡します):
Public Shared Function StreamToByteArray(input As Stream) As Byte()
Dim buffer As Byte() = New Byte(16 * 1024 - 1) {}
Using ms As New MemoryStream()
Dim read As Integer
While (InlineAssignHelper(read, input.Read(buffer, 0, buffer.Length))) > 0
ms.Write(buffer, 0, read)
End While
Return ms.ToArray()
End Using
End Function
編集:
私のStreamToByteArray
関数を単純に置き換えることができることを学びました:
Dim filePath as String = "Path\to\file"
Dim fileBytes as Byte() = System.IO.File.ReadAllBytes(filePath)