Solved

read INI files without interop

Posted on 2014-07-28
5
267 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:Charles Baldo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 40224187
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 26

Accepted Solution

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

Expert Comment

by:ste5an
ID: 40224210
These .config files also, at least in VB 2005 +, allow your settings to act like objects with strict type casting.

+1
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40224239
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:Charles Baldo
ID: 40229530
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

710 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