Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the type or namespace "TextFieldParser" could not be found

I am trying to use TextfieldParser that was found within Reading CSV files using C#. I am using VS 2010 and doing this in C#.

I keep on getting "the type or namespace "TextFieldParser" could not be found.."

When I try and add the using line, it will only go using Microsoft.VisualBasic; deep and not using Microsoft.VisualBasic.FileIO;

Any help would be great.

like image 515
user1158745 Avatar asked Mar 14 '13 20:03

user1158745


People also ask

What is TextFieldParser?

The TextFieldParser object provides methods and properties for parsing structured text files. Parsing a text file with the TextFieldParser is similar to iterating over a text file, while using the ReadFields method to extract fields of text is similar to splitting the strings.


1 Answers

In Visual Studio, right click on References in the Solution Explorer side panel. Click "Add Reference".

In that list be sure to check Microsoft.VisualBasic. Hit OK.

Now in the namespace, add Using Microsoft.VisualBasic.FileIO.

That will allow you to use TextFieldParser. For a good, easy example on how to use it, look here: http://geekswithblogs.net/brians/archive/2010/07/07/whats-a-nice-class-like-textfieldparser-doing-in-a-namespace.aspx

like image 62
Mark P. Avatar answered Sep 28 '22 18:09

Mark P.