Posting files to services in C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rjindal
    New Member
    • Oct 2008
    • 1

    Posting files to services in C#

    Hi,

    Is there a way in C# to post a file to a web service without using the File Browser control. The actual requirement is my application is generating an XML file and I need to post that XML file to a web service as a parameter. Please note I need to post the actual file not the content or path of the file. Is there any way to do this in C#?

    Thanks a lot in Advance!

    Ravi Jindal
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    Originally posted by rjindal
    Hi,

    Is there a way in C# to post a file to a web service without using the File Browser control. The actual requirement is my application is generating an XML file and I need to post that XML file to a web service as a parameter. Please note I need to post the actual file not the content or path of the file. Is there any way to do this in C#?

    Thanks a lot in Advance!

    Ravi Jindal
    what do you mean by "not the content or path"? webservice method can have parameters like string or XMLDocument as input for xml strings...
    The same method can then recreate the file at the server end....by writing to disk..

    Comment

    • Curtis Rutland
      Recognized Expert Specialist
      • Apr 2008
      • 3264

      #3
      So, you need to transfer a file across a web service, is that right?

      Well, you can make a [WebMethod] that takes a byte[] as a parameter. Then, on your program side, use a FileStream to read into a byte[]. Pass the byte[] to the service. On the service side, use another FileStream to write the buffer to disk.

      Comment

      Working...