1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| 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;
using System.Globalization;
using System.Collections.Specialized;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
////////foreach (string line in File.ReadLines("Bureau\\EVENT.txt"))
////////{
//////// string[] parts = line.Split(';');
//////// // var cust = new Customer();
//////// // cust.Name = parts[1];
//////// //listBox1.Items.Add
//////// // context.Customers.Add(cust);
////////}
string p = "E:\\PFE_2013\\input\\EVENT.txt"; // Spécification path
Encoding unicode = Encoding.ASCII;//type de codage
//1-Lecture de fichier
using (StreamReader sr = new StreamReader(p, unicode))
{
string line;
while ((line = sr.ReadLine()) != null)// tant que c'est pa la fin de fichier continuer à lire
{
listBox1.Items.Add(line.TrimStart(' '));
}//End While
}// End Using
for (int i = 0; i < listBox1.Items.Count; i++)
{
string[] souchaine;
souchaine = listBox1.Items[i].ToString().Split(' ');
listBox2.Items.Add(souchaine[0]);
listBox3.Items.Add(souchaine[1]);
listBox4.Items.Add(souchaine[2]);
listBox5.Items.Add(souchaine[3]);
}
}
}
} |
Partager