c#上传代码,拒绝访问
privatevoidbutton2_Click(objectsender,EventArgse){if(this.textBox3.Text==""|this.text...
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));
}
}
这段代码本地测试总是提示对路径****的访问被拒绝! 展开
{
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));
}
}
这段代码本地测试总是提示对路径****的访问被拒绝! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询