private void button2_Click(object sender, EventArgs e)
{
if (this.textBox3.Text == "" | this.textBox4.Text == "")
return;
WebClient MyClient = new WebClient();
string URL = this.textBox4.Text;
string FileName = this.textBox3.Text;
byte[] MyResponseArray = null;
try
{
MyResponseArray = MyClient.UploadFile(URL,FileName);
MessageBox.Show("文件上传成功!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception Err)
{
MessageBox.Show("文件上传失败!错误是:" + Err.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
MessageBox.Show("\n服务器的回复为:\n" + System.Text.Encoding.ASCII.GetString(MyResponseArray));
}
}
这段代码本地测试总是提示对路径****的访问被拒绝!
- - 405 这是什么情况?
追答405没遇到过!应该是权限的问题!你上传的时候,服务器应该是不让你上传!!你用的是什么服务器!