예제 #1
0
        private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string path = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();

            if (path.Substring(path.Length - 4) == ".txt")
            {
                GetText  text  = new GetText();
                string   data  = text.GetTxt(path);
                int      line  = text.TextOccurrences(data, Environment.NewLine);
                string[] data2 = text.DivisionText(data, Environment.NewLine);
                for (int i = 0; i < line; i++)
                {
                    try
                    {
                        ListViewItem listView = new ListViewItem();
                        string[]     data3    = text.DivisionText(data2[i], "----");
                        int          ID       = listView1.Items.Count + 1;
                        listView.Text = ID.ToString();
                        listView.SubItems.Add(data3[0]);
                        listView.SubItems.Add(data3[1]);
                        listView.SubItems.Add(data3[2]);
                        listView1.Items.Add(listView);
                        //    Console.WriteLine(data3[1]);
                    }
                    catch {
                        MessageBox.Show("请拖入程序保存的cookie文件!");
                        break;
                    }
                }
            }


            else
            {
                MessageBox.Show("请拖入.txt文本");
            }
        }