Stream an array of files to C# webservice

Posted on 2007-10-08
Last Modified: 2012-08-13

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, "")
    Me.MousePointer = vbNormal

and on serverside :

    public string SaveFile(string[] fileName, byte[] theFile, string Recipt)
        Recip = Recipt;

            string fileNameWithPath = Path.Combine(UploadPath, fileName[0]);
            FileStream fileStream = new FileStream(fileNameWithPath,
                FileMode.Create, FileAccess.Write);
            fileStream.Write(theFile, 0, theFile.Length);

        catch (Exception exp)
            return exp.ToString();
        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?

Question by:JamesBrian
    LVL 8

    Expert Comment

    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.

    Author Comment

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

    LVL 96

    Accepted Solution

    Something like this maybe:

            public void SaveFile(string fileNameList)
                string[] fileNames = fileNameList.Split(';');
                foreach (string file in fileNames)


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now