JamesBrian
asked on
Stream an array of files to C# webservice
Hi,
from my VB 6 client, I can easily stream a single file to my C# webservice using this code :
Dim objSOAPClient As New MSSOAPLib30.SoapClient30
FileName = "c:\test.pdf"
Dim btArr() As Byte
Open FileName For Binary Access Read As #1
ReDim btArr(LOF(1))
Get #1, , btArr()
Close #1
MsgBox objSOAPClient.Attachmentfr omstream(F ileName, btArr, "address@internet.com")
Me.MousePointer = vbNormal
and on serverside :
[WebMethod]
public string SaveFile(string[] fileName, byte[] theFile, string Recipt)
{
Recip = Recipt;
try
{
string fileNameWithPath = Path.Combine(UploadPath, fileName[0]);
FileStream fileStream = new FileStream(fileNameWithPat h,
FileMode.Create, FileAccess.Write);
fileStream.Write(theFile, 0, theFile.Length);
fileStream.Close();
ctr++;
}
catch (Exception exp)
{
return exp.ToString();
}
finally
{
}
SendMessage();
return "DONE";
}
But now I want to send an email with multiple attachments. I only want to make ONE call to the webservice.
Thus the question is : how do I stream an array of filenames from a VB6 client, and process them in my C# webservice?
from my VB 6 client, I can easily stream a single file to my C# webservice using this code :
Dim objSOAPClient As New MSSOAPLib30.SoapClient30
FileName = "c:\test.pdf"
Dim btArr() As Byte
Open FileName For Binary Access Read As #1
ReDim btArr(LOF(1))
Get #1, , btArr()
Close #1
MsgBox objSOAPClient.Attachmentfr
Me.MousePointer = vbNormal
and on serverside :
[WebMethod]
public string SaveFile(string[] fileName, byte[] theFile, string Recipt)
{
Recip = Recipt;
try
{
string fileNameWithPath = Path.Combine(UploadPath, fileName[0]);
FileStream fileStream = new FileStream(fileNameWithPat
FileMode.Create, FileAccess.Write);
fileStream.Write(theFile, 0, theFile.Length);
fileStream.Close();
ctr++;
}
catch (Exception exp)
{
return exp.ToString();
}
finally
{
}
SendMessage();
return "DONE";
}
But now I want to send an email with multiple attachments. I only want to make ONE call to the webservice.
Thus the question is : how do I stream an array of filenames from a VB6 client, and process them in my C# webservice?
You must create an Array with filenames and lengths of each file. Let's name it fileList. Then you can put all files in your byte[] theFile and split the array accordnig to fileList.
ASKER
Can you provide some code please ?
I think your approach might work, but I need code to get me started.
I think your approach might work, but I need code to get me started.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.