1

I'm trying to upload a file via WCF service. I can upload a file as a Stream but I need also a file name.

For test purpose, I've created a simple form with <input type='file' /> tag.

According to the article (http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP) there is a class:

[MessageContract]
public class RemoteFileInfo : IDisposable
{
    [MessageHeader(MustUnderstand = true)]
    public string FileName;

    [MessageHeader(MustUnderstand = true)]
    public long Length;

    [MessageBodyMember(Order = 1)]
    public Stream FileByteStream;

    public void Dispose()
    { 
        if (FileByteStream != null)
        {
            FileByteStream.Close();
            FileByteStream = null;
        }
    }   
}

and now - how to pass the file value (from that input tag) to that class ?

Tony
  • 12,405
  • 36
  • 126
  • 226
  • 1
    Who is consumer/client of your service? Is it REST or SOAP service? – Ladislav Mrnka Apr 13 '12 at 08:23
  • 1
    If its a REST service then hopefully you can find a similar solution here : http://stackoverflow.com/questions/9734941/upload-file-from-html-form-multipart-form-data-to-wcf-rest-service-as-a-stream/10090971#10090971 – Rajesh Apr 13 '12 at 09:18

0 Answers0