用控件比较好,自己写的WebClient不太好用的,好像我测试也没有通过参见下面http://expert.csdn.net/Expert/topic/1439/1439735.xml?temp=.8572657

解决方案 »

  1.   

    public void UploadFile(object sender , EventArgs E)
    {
    //check if the fileposted is bot null
    if(myFile.PostedFile!=null)
    {
    //some string manipulations to extract the filename from the full file path
    string nam = myFile.PostedFile.FileName ;
    int i= nam.LastIndexOf("\\") ;
    string newnm =nam.Substring(i) ; //save the file to the destination path on your server
    //change this path as per your needs (remember the path you specify should exist and have 'write' access)
    //Note: I have used "c:\\" etc the "\\" is because I have to give a escape character 
    //in a string
    myFile.PostedFile.SaveAs("c:\\inetpub\\wwwroot\\upload\\"+newnm) ;

    //Get the various properties of the Uploaded file
    fname.Text=myFile.PostedFile.FileName;
    fenc.Text=myFile.PostedFile.ContentType ;
    fsize.Text=myFile.PostedFile.ContentLength.ToString();
    }
    }