1

I'm using C#, WinForm, This code.

I have modified the XML file and uploaded it to the web server, but the XML file is missing from the web server.

but debugging is good working and WebClient Download works well.

using (WebClient client = new WebClient())
{
     client.Credentials = new NetworkCredential("id", "password");
     client.UploadFile("http://abcdef.com/test.xml", @"C:\test.xml");
}
Prio Choi
  • 13
  • 1
  • 5
  • And the server side code looks like? I think you should read this: https://msdn.microsoft.com/en-us/library/36s52zhs(v=vs.110).aspx – Daniel Stackenland Apr 04 '17 at 06:49
  • Ah, I think I understood it. So do you need to write code on the server to use the code? Thanks. – Prio Choi Apr 04 '17 at 07:13
  • Yes :-) The WebClient uploads the data, then you need server-side code to do what you want with it (save as a file or whatever...) I make this an answer. – Daniel Stackenland Apr 04 '17 at 09:56
  • Possible duplicate of [Send a file via HTTP POST with C#](https://stackoverflow.com/questions/1131425/send-a-file-via-http-post-with-c-sharp) – Ian Kemp Jan 21 '19 at 11:14

1 Answers1

1

The WebClient.UploadFile Method uploads the data, then you need server-side code to do what you want with it (save as a file or whatever...)

Take a look at this on MSDN: http://msdn.microsoft.com/en-us/library/36s52zhs(v=vs.110).aspx

Daniel Stackenland
  • 3,149
  • 1
  • 19
  • 22