4 Replies - 319 Views - Last Post: 10 November 2017 - 05:27 AM Rate Topic: -----

#1 t3cho  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 223
  • Joined: 27-May 14

Configuration file .ini , .json .xml

Posted 09 November 2017 - 06:12 AM

Which format is best to use for configuration file .

Example ...

I need to store data such as

User:DreamInCode
Password:NoHashNeed
Site:www.dreamincode.net
Members:
Anel
Damir
Test1
DemoUser3
Example5
LogTime:12

I would go further with .ini file but main problem is i don't know how to read multiple members from one key value: PS. I don't know how many users there will be.

Json is good method to proceed by my opinion.

Any example or smth similar ??

Is This A Good Question/Topic? 0
  • +

Replies To: Configuration file .ini , .json .xml

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5899
  • View blog
  • Posts: 20,142
  • Joined: 05-May 12

Re: Configuration file .ini , .json .xml

Posted 09 November 2017 - 06:44 AM

Do you expect users/developers to manually edit the configuration file with notepad or some other text editor? Do you need your developers to inspect the configuration file manually using notepad or some other text editor?

If the the answer is no, use XML. If the answer is yes, JSON will be easier.

Any which way, use serialization classes to read/write the configuration files instead of writing code to parse them. JSON.net's JSON serialization, or .NET Framework's XML serialization should be what you are using.
Was This Post Helpful? 1
  • +
  • -

#3 t3cho  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 223
  • Joined: 27-May 14

Re: Configuration file .ini , .json .xml

Posted 09 November 2017 - 06:54 AM

Thanks for fast answer.

Yes, end user will edit that configuration file. He will only change the list of members everday, all other are initial configuration which won't change.

Also i thought about serialization by using NewtonSoft JSON but assuming this will be a Windows service to run in background i wouldn't go with additional .dll's which i need to include. I would love it to be just one .exe and one configuration file.

But currently i have in mind


.exe ( Windows service )
.ini ( basic configuration 1key 1 value)
.txt ( list of members )
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5899
  • View blog
  • Posts: 20,142
  • Joined: 05-May 12

Re: Configuration file .ini , .json .xml

Posted 09 November 2017 - 08:21 AM

A Windows Service doesn't have to all live in a single executable.

If you need to update an ini file or text file daily, you may want to re-think your process. Why does it have to be in a configuration file? Why not have a live database that stores that data. That way you can have a friendly (web- or native) GUI front end for the database table, as well as, have options for auditing, logging, and security.
Was This Post Helpful? 1
  • +
  • -

#5 t3cho  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 223
  • Joined: 27-May 14

Re: Configuration file .ini , .json .xml

Posted 10 November 2017 - 05:27 AM

I agree with you but it would be better to have only one file for application.

Never mind i went with .ini and .txt file

Day.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1