コード例 #1
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            //上传的程序段
            //这是文件将上传到的服务器的绝对目录
            string strBaseLocation = Server.MapPath("../Upload/CRMUpdate/");
            string UnzipPath       = strBaseLocation + "\\" + DateTime.Now.ToString("yyyyMMdd");

            if (FileUpload1.PostedFile.ContentLength != 0) //判断选取对话框选取的文件长度是否为0
            {
                string NewName = UnzipPath + FileUpload1.PostedFile.FileName;
                FileUpload1.PostedFile.SaveAs(NewName);
                //执行上传,并自动根据日期为文件命名,确保不重复
                ShowMessage("上传成功");
                Zipper.UnZip(NewName, UnzipPath);
                //move dir
            }
        }