using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.openFileDialog1 = new OpenFileDialog();
openFileDialog1.Title = "打开代理文件";
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;
openFileDialog1.AddExtension = true;
openFileDialog1.Multiselect = false;
openFileDialog1.Filter = "*.txt|*.txt|*.*|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
FileInfo f = new FileInfo(openFileDialog1.FileName);
StreamReader ce = f.OpenText();
this.richTextBox1.Text = ce.ReadToEnd();
ce.Close();
for (int i = 0; i < richTextBox1.Lines.Length; i++)
{
this.listBox1.Items.Add(richTextBox1.Lines[i]);
}
}
}
private string getff(string k)
{
try
{
int i = k.IndexOf(' ');
k = k.Remove(0, i + 1);
i = k.IndexOf(" H");
k = k.Remove(i, k.Length - i);
return k;
}
catch
{
return "aaa";
}
//try
//{
// int i1 = 0;
// int i2 = 0;
// int i3 = 0;
// for (int i = 0; i < k.Length; i++)
// {
// if (k[i] ==' ')
// {
// i1 = i;
// }
// }
// MessageBox.Show(k.Length.ToString());
// string of = k.Remove(0, i1 + 1);
// int b = 0;
// for (int i = 0; i < of.Length; i++)
// {
// if (k[i] == ' ')
// {
// if (b == 0)
// {
// b++;
// }
// else if (b == 1)
// {
// i3 = i;
// }
// }
// }
// return of.Remove(i3, k.Length - i3);
//}
//catch
//{
// return "aaa/r/n";
//}
}
private void button3_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.listBox1.Items.Count; i++)
{
this.listBox1.Items[i] = getff(this.listBox1.Items[i].ToString());
}
}
private void button2_Click(object sender, EventArgs e)
{
this.saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Title = "保存代理文件";
saveFileDialog1.OverwritePrompt = true;
saveFileDialog1.CreatePrompt = true;
saveFileDialog1.AddExtension = true;
saveFileDialog1.Filter = "*.txt|*.txt|*.*|*.*";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
this.richTextBox1.Text = "";
for (int i = 0; i < this.listBox1.Items.Count; i++)
{
this.richTextBox1.AppendText(this.listBox1.Items[i].ToString() + "/n");
}
StreamWriter nn = new StreamWriter(saveFileDialog1.FileName);
nn.Write(this.richTextBox1.Text);
nn.Close();
}
}
}
}