Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionusing System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace WindowsFormsApplication3 { public partial class Ecran : Form { StreamReader Reader; public Ecran() { InitializeComponent(); } private void BrnParcour_Click(object sender, EventArgs e) { OpenFileDialog Open = new OpenFileDialog(); Open.Filter = "*.txt (Fichier Texte) |*.Txt"; if (Open.ShowDialog() == DialogResult.OK) { Reader = new StreamReader(Open.FileName); txtData.Text = Reader.ReadToEnd(); } } } }
private void btrExec_Click(object sender, EventArgs e) { string[] lines = System.IO.File.ReadAllLines(Fichier); foreach (String l in lines) { foreach (string l in debut){ Console.WriteLine(l.Substring(int 20)); }
private void btnExec_Click(object sender, EventArgs e) { string[] lines = System.IO.File.ReadAllLines(Fichier); foreach (String l in lines) { if (l.StartsWith(debut)) { Console.WriteLine(l); } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace WindowsFormsApplication3 { public partial class Ecran : Form { String Fichier = @"C:\Prev.txt"; String debut = "31"; String fin = "39"; String zone; public Ecran() { InitializeComponent(); } private void BrnParcour_Click(object sender, EventArgs e) { OpenFileDialog Open = new OpenFileDialog(); Open.Filter = "*.txt (Fichier Texte) |*.Txt"; if (Open.ShowDialog() == DialogResult.OK) { StreamReader reader = new StreamReader(Open.FileName); txtData.Text = reader.ReadToEnd(); reader.Close(); } } private void btn_Exec_Click_1(object sender, EventArgs e) { string[] lines = System.IO.File.ReadAllLines(Fichier); foreach (String l in lines) { if (l.StartsWith(fin)) { zone = l.Substring(229, 12); Console.WriteLine(zone); } } } } }
} // initialisation de l'écriture dans un fichier StreamWriter ecrire = new StreamWriter(Fichier); if (l.StartsWith(debut)) { try { // mon but remplacer la premier ligne de mon fichier par la partie qui ne bouge pas sur cette ligne et je remplace la fin par la zone mémorisée. ligne1 = l.Substring(0, 227) + zone; }