コード例 #1
0
        /// <summary>
        /// 把指定cookie写入指定文件file
        /// </summary>
        /// <param name="setting"></param>
        /// <param name="cookie"></param>
        public static void WriteCookiesToDisk(string file, CookieContainerForSave cookie)
        {
            Stream          stream    = File.Create(file);
            BinaryFormatter formatter = new BinaryFormatter();

            formatter.Serialize(stream, cookie);
            stream.Flush();
            stream.Dispose();
        }
コード例 #2
0
        private async void Form1_LoadAsync(object sender, EventArgs e)
        {
            if (File.Exists("cookie"))
            {
                ForSave           = StreamHelper.ReadCookiesFromDisk("cookie");
                IsLoggded         = ForSave.IsLogged;
                tsdmHelper.Cookie = ForSave.CookieContainer;
            }
            progressBar1.Maximum = 2;
            progressBar1.Value   = 0;
            if (IsLoggded)
            {
                UserinfoCheckAsync();
            }
            else
            {
                logpanel.Visible  = true;
                VerifyImage.Image = Image.FromStream(await tsdmHelper.VerifyCodeAsync());
            }
            progressBar1.Value = 1;
            Json Json = await tsdmHelper.GetForumAsync("");

            foreach (var str in Json.group)
            {
                Button btn = new Button
                {
                    Name = "btn" + str.gid.ToString()
                    ,
                    Text = str.title.ToString()
                    ,
                    AutoSize = true
                    ,
                    Tag = str.gid.ToString()
                };
                btn.Click += GroupButton_ClickAsync;
                flowLayoutPanel3.Controls.Add(btn);
            }
            progressBar1.Value = 2;
        }