Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VB.Net to read in a text file

Status
Not open for further replies.

Jabez3rd

Programmer
Feb 6, 2003
9
US
I'm creating an ASP.Net application using VB.Net code behind pages. One of the last pieces of functionality I need to add to this appliction is the ability to read in semicolon delimited text files.

I've considered using "File.OpenText(FILE_NAME)" and looping through each record to obtain the information I need. However, I'ver never done this with a .Net application and was wondering if I am on the right track or is there a better method to obtain the result I want?

Thanks!
 
Reading the file in this way is the standard way to do it. But lately I prefer to access the file via SQL and oledb jet connection, since this allows you to bind a data consumer to it directly, and SQL in my opinion is more elegant than looping through the file.

The only problem is that the default delimiter for text files with jet is comma, and I've not yet found how to make it recognise anything else, but there must be a way.

I also sometimes use this method to access excel files rather than using excel COM, as again it is more elegant

Finally, I've only tried this with excel, but you can also update the files using the same method

Mark [openup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top