コード例 #1
0
        void ReleaseDesignerOutlets()
        {
            if (Img1 != null)
            {
                Img1.Dispose();
                Img1 = null;
            }

            if (Btn1 != null)
            {
                Btn1.Dispose();
                Btn1 = null;
            }

            if (Img3 != null)
            {
                Img3.Dispose();
                Img3 = null;
            }

            if (Btn3 != null)
            {
                Btn3.Dispose();
                Btn3 = null;
            }

            if (Img2 != null)
            {
                Img2.Dispose();
                Img2 = null;
            }

            if (Btn2 != null)
            {
                Btn2.Dispose();
                Btn2 = null;
            }

            if (Img4 != null)
            {
                Img4.Dispose();
                Img4 = null;
            }

            if (Btn4 != null)
            {
                Btn4.Dispose();
                Btn4 = null;
            }
        }
コード例 #2
0
ファイル: AuctionForm.aspx.cs プロジェクト: hillterry/Jetso
    protected void Button3_Click(object sender, System.EventArgs e)
    {
        Random rnd  = new Random();
        string tiem = DateTime.Now.ToString("yyyyMMdd");

        if (Img3.HasFile)
        {
            string imageName       = Img3.FileName;
            string extension_image = Path.GetExtension(imageName);
            bool   extension_type  = extension_image.Equals(".jpeg") || extension_image.Equals(".png") || extension_image.Equals(".jpg") || extension_image.Equals(".gif") || extension_image.Equals(".bmt");
            if (extension_type)
            {
                int    num        = rnd.Next(5000, 10000);
                string path_image = "file/image/" + tiem;
                DmFramework.IO.FileHelper.EnsureDirectory(System.Web.HttpContext.Current.Server.MapPath("../../" + path_image));
                try
                {
                    Img3.SaveAs(System.Web.HttpContext.Current.Server.MapPath("../../" + path_image + "/" + num.ToString() + extension_image));
                    Label3.Text = "上传成功";
                }
                catch (Exception ex)
                {
                    Label3.Text = ex.Message;
                }
                frmProductImage3.Text = path_image + "/" + num.ToString() + extension_image;
            }
            else
            {
                Label3.Text = "图片格式为jpeg,png,jpg,gif,bmt";
            }
        }
        else
        {
            Label3.Text = "文件为空,请浏览要上传文件!";
        }
    }