Sending large files to a web service

xml Egypt
  • 14 years ago

    Hi i am making a web service that receive a file and save it on the server, i have made a method that takes byte array -buffer- and string -filename- then use Stream.Write() method to wsave it.

    I have made a windows app that read a file into a byte array Stream.Read() then call the webservice method and pass the array and the filename. if the file was large i cannot read all of it into the byte array so i have made the byte array length only 3000 then looped the file and each time in the loop read a 3000 byte then pass it to the web service method:

    byte[] buffer = new byte[3000];

    while(stream.Read(buffer,0,buffer.Length) != 0)

    {

    myService.ServiceSendMethod(buffer , fileName);

    }

    now the problem is , if the file was say 70 MB, then it will be a looooooooong loop and each time in the loop i am calling a webserive method which takes a time to be called, so time is too long to send it, furthermore the application is freezed until the file is sent.

    So plz can anyone help me find the best way and more efficient? 

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perl - The only language that looks the same before and after RSA encryption.” - Keith Bostic