User:Zhaoxia

using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient;

public partial class filesUP : System.Web.UI.Page {   protected void Page_Load(object sender, EventArgs e)    { }   protected void btnload_Click(object sender, EventArgs e)    { myjoin p = new myjoin; string filePath="",fileExtName="",mFileName,mpath; System.Text.StringBuilder strMsg = new System.Text.StringBuilder("上传的文件信息:

");       if ("" != FileUP.PostedFile.FileName)        {             //取文件路径            filePath = FileUP.PostedFile.FileName;            //取得文件扩展名            fileExtName = filePath.Substring(filePath.LastIndexOf(".")+1);            try            {                //取得与WEB服务器上的指定的虚拟路径相对应的文件路径                mpath = Server.MapPath("~/upfiles/");                //取得文件名                mFileName = filePath.Substring(filePath.LastIndexOf("\\") + 1);   //采用Substring字符串截取到最后一个“\\”后面的字符，就能截取掉路径，只取出文件名                //取得上传文件的信息                strMsg.Append("上传的文件类型：" + FileUP.PostedFile.ContentType.ToString + " ");               strMsg.Append("客户端文件路径：" + FileUP.PostedFile.FileName + " ");               strMsg.Append("上传文件的文件名：" + mFileName + " ");               strMsg.Append("上传的文件扩展名：" + fileExtName);                //保存上传文件到指定目录                FileUP.PostedFile.SaveAs(mpath + mFileName);                strstate.Text = strMsg.ToString;            }            catch (Exception error)            {                Response.Write(error.ToString);            }        }    } }