I try to fill up a record list that works in a previous code but it don't in the current one. what is strange the loop while doesn't look running at all, so filing up record list from text file posted also doesn't happen. also it is a problem the beginning of the text file. it starts with a code. I try to get it also but running the code noting happens, noting is running. no error msg Please have a look and help me as it is possible.
the code:
[CODE lang="csharp" title="hotelorder1"] string olvas = @"c:\Users\Public\textfiles\pitypang.txt";
List<pitypang00> adatok = new List<pitypang00>();
int i = 0;
int i2 = 0;
int kod0 = 0;
int utolso = 0;
try
{
// Open the text file using a stream reader.
using (var sr = new StreamReader(olvas, Encoding.Default))
{
// Read the stream as a string, and write the string to the console.
//Console.WriteLine(sr.ReadToEnd());
while (!sr.EndOfStream)
{
string sor = sr.ReadLine();
string[] record = sor.Split(' ');
adatok.Add(new pitypang00());
if (i == 0) { kod0 = Convert.ToInt32(record[0]); }
else
{
adatok.foglaloszam = Convert.ToInt32(record[1]);
adatok.szobaszam = Convert.ToInt32(record[2]);
adatok.erkezesinapsorszama = Convert.ToInt32(record[3]);
adatok.tavozasinapsorszam = Convert.ToInt32(record[4]);
adatok.vendegszam = Convert.ToInt32(record[5]);
adatok.kernekreggelit = Convert.ToInt32(record[6]);
adatok.vendegazonosito = record[7];
utolso++;
Console.WriteLine(i+" "+ record[7]);
i++;
}
}
sr.Close();
for (i2 = 1; i2 <= utolso; i2++){
Console.WriteLine(
" Foglaloszam "+ adatok.foglaloszam+
" Szobaszam "+ adatok.szobaszam+
" Erkezesinap\n sorszama "+ adatok.erkezesinapsorszama);
}[/CODE]
the code:
[CODE lang="csharp" title="hotelorder1"] string olvas = @"c:\Users\Public\textfiles\pitypang.txt";
List<pitypang00> adatok = new List<pitypang00>();
int i = 0;
int i2 = 0;
int kod0 = 0;
int utolso = 0;
try
{
// Open the text file using a stream reader.
using (var sr = new StreamReader(olvas, Encoding.Default))
{
// Read the stream as a string, and write the string to the console.
//Console.WriteLine(sr.ReadToEnd());
while (!sr.EndOfStream)
{
string sor = sr.ReadLine();
string[] record = sor.Split(' ');
adatok.Add(new pitypang00());
if (i == 0) { kod0 = Convert.ToInt32(record[0]); }
else
{
adatok.foglaloszam = Convert.ToInt32(record[1]);
adatok.szobaszam = Convert.ToInt32(record[2]);
adatok.erkezesinapsorszama = Convert.ToInt32(record[3]);
adatok.tavozasinapsorszam = Convert.ToInt32(record[4]);
adatok.vendegszam = Convert.ToInt32(record[5]);
adatok.kernekreggelit = Convert.ToInt32(record[6]);
adatok.vendegazonosito = record[7];
utolso++;
Console.WriteLine(i+" "+ record[7]);
i++;
}
}
sr.Close();
for (i2 = 1; i2 <= utolso; i2++){
Console.WriteLine(
" Foglaloszam "+ adatok.foglaloszam+
" Szobaszam "+ adatok.szobaszam+
" Erkezesinap\n sorszama "+ adatok.erkezesinapsorszama);
}[/CODE]