Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 12th, 2003, 09:33 PM
Kis Kis is offline
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default INI files


I am new to c#. So can you please tell me how to use INI kind of stuff in c#?

Like i have one INI file
************** abc.ini************
[info]
key=ABC
symbol=logo
value=12

[languages]
009=English
000=french ... etc.
**********************************

It no need to use ini file, file can be of any type. I want to read from this file.

Reply With Quote
  #2 (permalink)  
Old December 15th, 2003, 10:45 AM
Authorized User
 
Join Date: Nov 2003
Location: Milwaukee, Wisconsin, USA.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to KABay
Default

Look into using an XML file instead. C# has a very powerful set of classes that allow you to read, search & modify XML 'documents', which are still human readable and editable.
Reply With Quote
  #3 (permalink)  
Old December 17th, 2003, 05:02 AM
Kis Kis is offline
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply KABay
But what i though as it is very easy to understand any INI file rather then XML file.
Actualy i want to have something like different Sections, so just use a loop to get al the keys in one section. I don't want to write everything as hard coded. If you can suggests me something for this then :)

Any way i'll try to use XML :)

Thx...

Reply With Quote
  #4 (permalink)  
Old April 2nd, 2015, 05:04 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2015
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default RE: INI files

Here is a library for both reading and writing INI files in C#.
You can achieve exactly what you have mentioned: "just use a loop to get al the keys in one section"
For example something like this:
Code:
IniFile ini = new IniFile();
ini.Load("abc.ini");

IniSection infoSection = ini.Sections["info"];
foreach (IniKey key in infoSection.Keys)
{
    string keyName = key.Name;
    string keyValue = key.Value;

    // Do something...
}

IniSection languagesSection = ini.Sections["languages"];
foreach (IniKey key in languagesSection.Keys)
{
    string keyName = key.Name;
    string keyValue = key.Value;

    // Do something...
}
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
browscap.ini ddawson59 BOOK: Beginning ASP 3.0 0 April 17th, 2006 02:15 PM
Reading .ini files anisurr C++ Programming 2 February 7th, 2006 05:02 PM
ini file ptop C++ Programming 0 January 30th, 2006 06:29 AM
How to read and update .INI files using Pure C ?? Poonam C++ Programming 1 March 24th, 2005 01:22 AM
php.ini allang Beginning PHP 1 November 20th, 2003 09:09 PM



All times are GMT -4. The time now is 01:28 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.