Help with texfile

giulione Messages postés 2 Date d'inscription lundi 14 février 2005 Statut Membre Dernière intervention 26 juin 2006 - 20 juin 2006 à 03:10
cs_Bidou Messages postés 5487 Date d'inscription dimanche 4 août 2002 Statut Membre Dernière intervention 20 juin 2013 - 20 juin 2006 à 08:14
Hi everibody,
i need some help,
i've got this text file
---------------------------- start ------------------------------

GENUARDI ADOLFO
90100
04800530828
VIA ORETO 139
MARCHESE SALVATORE
90100
00464940824
PIAZZA CARMINE 40
LA MENDOLA LILIANA
90018
04109670820
VIA BAGNI 1
BOVA AGOSTINO
90018
04572110825
CORSO UMBERTO E MARGHERITA 37
RESTIVO ANTONINO
90018
04357320821
VIA PANDOLFINI F.D. N.24
CORRERA MARIA TERESA
90040
03620280820
VIA PROVINCIALE 76
BAIAMONTE TERESA
90046
04390880823
VIA FICATELLO PANTUSO 99
INGROMODA SRL
90124
03761640824
VIALE REGIONE SICILIANA 4325
ARNONE SCIMECA CARLO
90123
02100790829
CORSO DEI MILLE 731
CARCIONE MARIA LUISA
90100
04272210826
VIA GALLETTI 126/0
VITELLO ROSARIO (CHIUSO) CORSO CAMILLO F. APRILE 47/49
90100
02100850821
CORSO CAMILLO F. APRILE 47/49
FAVA ANTONINO
90100
02419470824
VIA UMBERTO SOLARINO 1/3/5/7
RICCOBONO STEFANO
90100
04248650824
VIA SFERRACAVALLO 45
CRACOLICI PIERA ELISA
90100
02100050828
VIA TORRETTA 26
INCANDELA ROBERTO
90100
02100660824
LARGO EDOARDO ALFANO 17
MINNELLI DANIELA-ELLEDI
90133
04445250824
VIA ROMA 212/214
MASTROLEMBO GIUSEPPE
90128
04671240820
VIA GUSTAVO ROCCELLA 52/L
DI GIOVANNI GIOSUE
90100
00402350821
VIA ROMA 59/A
ALIMENTARI SAN LEOLUCA SAS-LANZA LEONARDA
90034
03618940823
VIA PORTOSALVO 25
CAMILLERI MARCELLO
90100
04429650825
VIA MALASPINA 88
EDILVENEZIA SRL
90032
03177900820
CONTRADA SOTTOMADONNA
CANNATA ANGELO
90100
02605570825
VIA VAL DI MAZARA 16
SARC SRL C/A SIG. BARGIACCHI
40131
04207370372
VIA DEL CHIU' 68
TARAVELLA MARIA ANTONIETTA
90039
00796250827
CORSO VITTORIO EMANUELE 426
---------------------------- end ----------------------------------
Well i'm tryng to read the file and count 4 line and thake the text ,count another 4 line and take the text,count another 4 line and take the text,so till the end of the text

1 réponse

cs_Bidou Messages postés 5487 Date d'inscription dimanche 4 août 2002 Statut Membre Dernière intervention 20 juin 2013 61
20 juin 2006 à 08:14
Hi,
Maybe you can try this :

System.IO.

StreamReader sr =
new System.IO.
StreamReader(myPath);

string line =
null;

int lineNb = 0;

do
{
   line = sr.ReadLine();
   lineNb++;
  
if (lineNb % 4 == 0)
   {
     
Console.WriteLine(line);
     
// Some other stuff, like inserting the value in an array
   }
}
while (line !=
null);

// Disposing...
sr.Close(); sr =
null;

<hr size="2" /> VC# forever
=13319
0
Rejoignez-nous