Error while reading a text file - Logging line number and record
hi
i working on .net 3.5 windows application.
arecord
brecord
crecord
drecord
brecord
crecord
arecord
brecord
crecord
drecord
zrecord
, goes on
i store records in different array objects. arrarecords, arrbrecords , arrcrecords.....
i use forloop loop through each array , individual values(date field, name, time, integer, string) using substring function , write output file.
i error while reading individual values each record if record not in expected format.
length less expected
alphanumeric value encountered when expected value integer
if there space between characters , trying convert integer or double.
date time value not in expected format , errro occurs while converting
i cannot validate each field before reading because size of file huge , number of files processed more.
when there error, execution goes catch block , skips processing of other records.
if error, want log line number of record in text file , record value in error log file , continue processing of next records.
since store records in array , use multiple loops, not line number.
if there unexpected error , execution goes catch block. there way identify exact record caused issue @ runtime?
can use nested try catch blocks process each record? best approach skip reocrds errors , continue processing valid records?
thanks
ashok
can show code. can read lines @ time (incrementing line counter)_ , use string fucntions bust things apart.
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment