Archana,
Which part is breaking exactly? Is it breaking when it tries to read the
file or breaking when it tries to write to the file?
From the information provided, I agree with Marc. It sounds like some piece
of the data in the csv file might have a comma in it causing your columns to
be off. It might be a good idea to write something that will count the
commas in each line and output it to you so you can check for the error line.
Otherwise, I have found that it is usually safer to use tab delimited files
rather than comma delimited files. The reasoning for this is that it is
usually more likely to have table data with commas in it than table data with
tabs in it.
If you think your data may contain commas or tabs, it is even safer to use
excel files, but it will require more effort and the use of Visual Studio
Tools for Office.
"archana" wrote:
Hi,
thanks for your reply.
I will elaborate my question more clearly. See i have once csv file
which if i open using oledb in datatable is working. then what i did
is open that file using streamreader and write to some temp file using
streamwriter with default encoding. Here why i did this is i want to
add some text as first row so i am counting commas in first line by
opening csv file using streamreader and then insering those many
commas as first columns with data wherever want. Uptil now this logic
was working properly since last 1 year. suddenly it starts giving eror
for one file.
So i am not understanding is it related to encoding which i set or
something else?
Please help me asap.
thanks in advance.