WebClient UploadFile不起作用 [英] WebClient UploadFile Does Not Work

查看:351
本文介绍了WebClient UploadFile不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#,WinForm,这段代码。

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

我修改了XML文件并将其上传到Web服务器,但XML文件丢失了网络服务器。

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

但调试工作正常,WebClient下载效果很好。

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");
}


推荐答案

WebClient.UploadFile方法上传数据,那么你需要服务器端代码来做你想做的事情(保存为文件或其他...)

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...)

在MSDN上看一下这个:
http:// msdn。 microsoft.com/en-us/library/36s52zhs(v=vs.110).aspx

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

这篇关于WebClient UploadFile不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆