代碼能貼點?
label3.Text = "上载网址
private void button4_Click(object sender, System.EventArgs e)
{//浏览上载文件
if(this.openFileDialog1.ShowDialog()==DialogResult.OK)
{
this.textBox3.Text=this.openFileDialog1.FileName;
}
}
private void button3_Click(object sender, System.EventArgs e)
{//上载文件
if(this.textBox3.Text==""|this.textBox4.Text=="")
return;
WebClient MyClient=new WebClient();
string URL=this.textBox3.Text;
string FileName=this.textBox4.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));
}