Solved

read INI files without interop

Posted on 2014-07-28
5
251 Views
Last Modified: 2014-07-30
I have an older (very older) vb6 system that we are moving into vb.net.  We have a lot of very needed INI files, that are very useful and may never be converted to xml or .config   We currently have interop methods to read them.  I would like to obsolete those and deprecate them.    I have written some rudimentary text parsing that work well with INI files that are exact or do not need a lot of parse.   Can anyone point me to open source examples, hopefully in vb or at least c#.
0
Comment
Question by:charlesbaldo
5 Comments
 
LVL 25

Expert Comment

by:Shaun Kline
Comment Utility
If you are taking the time to upgrade a VB6 application to VB.Net, you should reconsider changing the INI files to .config files, as these files were designed to replace the INI files. These .config files also, at least in VB 2005 +, allow your settings to act like objects with strict type casting.

If you choose not to go the .config route, another option would be to move these settings into a database table, as this would allow easy modification of the settings and near immediate access to the change to all installations (if you are not writing standalone applications).

If neither of these are desired, there are many file reading samples that can be found on the web. One approach is to use the StreamReader to open the file and read the contents.
0
 
LVL 25

Accepted Solution

by:
Shaun Kline earned 500 total points
Comment Utility
You can find an example of the Streamreader here: http://msdn.microsoft.com/en-us/library/f2ke0fzy(v=vs.110).aspx
0
 
LVL 32

Expert Comment

by:Stefan Hoffmann
Comment Utility
These .config files also, at least in VB 2005 +, allow your settings to act like objects with strict type casting.

+1
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
Why don't you want to use GetPrivateProfileString? When working with old files, you need to use old mechanism.

Check http://emoreau.com/Entries/Articles/2003/05/Applications-Settings-in-VBNet.aspx
0
 

Author Closing Comment

by:charlesbaldo
Comment Utility
Sean thats What I end up doing.

This is no small application, millions of existing lines of vb6 code.  The migration must be gradual
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now