代理刮刀错误

时间:2017-08-14 07:56:06

标签: c#

我已经编写了一个代理程序,但我遇到了一些问题 - 特别是这两个错误。

错误1

  

只有赋值,调用,递增,递减,等待和新对象表达式才能用作语句而且

错误2

  

'System.Windows.Forms.ListBox.ObjectCollection'不包含'Item'的定义,也没有扩展方法'Item'接受类型'System.Windows.Forms.ListBox.ObjectCollection'的第一个参数' (您是否缺少using指令或程序集引用?)

这是我的C#文件:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Login
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.Net.WebRequest request = System.Net.HttpWebRequest.Create("http://awmproxy.net/freeproxy.php");
            System.Net.WebResponse response = request.GetResponse();
            System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream());
            string newestversion = sr.ReadToEnd();
            System.Text.RegularExpressions.Regex expression = new System.Text.RegularExpressions.Regex("[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:[0-9]{1,5}");
            System.Text.RegularExpressions.MatchCollection mtac = expression.Matches(code);
            foreach (Match itemcode in mtac)
            {
                listBox1.Items.Add(itemcode);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if ((listBox1.Items.Count == 0))
            {
                MessageBox.Show("Please Scrape Proxies First.", "ALERT!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                System.IO.StreamWriter S_W;
                string[] itms;
                listBox1.Items.ToString;
                SaveFileDialog save = new SaveFileDialog();
                int it;
                save.FileName = "Grabbed Proxies";
                save.Filter = "Grabbed Proxies (*.txt)|*.txt|ALL Files (*.*)|*.*";
                save.CheckPathExists = true;
                save.ShowDialog(this);
                S_W = new System.IO.StreamWriter(save.FileName);
                for (it = 0; (it
                            <= (listBox1.Items.Count - 1)); it++)
                {
                    S_W.WriteLine(listBox1.Items.Item[it]);
                }

                S_W.Close();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
        }

        public string code { get; set; }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }


}

0 个答案:

没有答案