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
|
private void btTri_Click(object sender, EventArgs e)
{
string ph1 = "Docnid:";
string ph2 = "Type";
string ph3 = "Motivati";
string[] valeurs; //tableau des données a stocker en BD
string ligne; //ligne courante du fichier
string temp = ""; //variable temporaire qui stocke les données
StreamReader st = new StreamReader("c:\\temp\\mail.txt", System.Text.Encoding.Default); //stream du fichier
while ((ligne = st.ReadLine()) != null)
{
if (System.Text.RegularExpressions.Regex.IsMatch(ligne, ph1, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
valeurs = ligne.Split(':');
temp = valeurs[1];
}
else if (System.Text.RegularExpressions.Regex.IsMatch(ligne, ph2, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
valeurs = ligne.Split(':');
temp = temp + " ; " + valeurs[1];
}
else if(System.Text.RegularExpressions.Regex.IsMatch(ligne, ph3, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
// ligne.Trim();
//ligne.Split(Environment.NewLine.ToCharArray());
temp = temp + ";" + ligne.ToString();
MessageBox.Show(temp);
}
}
} |
Partager