• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1097
  • Last Modified:

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?



0
JamesBrian
Asked:
JamesBrian
1 Solution
 
slado2Commented:
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.
0
 
JamesBrianAuthor Commented:
Can you provide some code please ?
I think your approach might work, but I need code to get me started.

0
 
Bob LearnedCommented:
Something like this maybe:

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

Bob
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now