Link to home
Start Free TrialLog in
Avatar of JamesBrian
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.Attachmentfromstream(FileName, 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(fileNameWithPath,
                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?



Avatar of slado2
slado2

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.
Avatar of JamesBrian

ASKER

Can you provide some code please ?
I think your approach might work, but I need code to get me started.

ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial