2 Replies - 642 Views - Last Post: 02 January 2013 - 04:35 PM Rate Topic: -----

#1 CodeMonkey65  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 02-January 13

updating a .cfg file

Posted 02 January 2013 - 04:26 PM

Hi all

Just wondering how I would update a config file in order to change some of its values. This is just a sample config to show you want I mean

// graphics

Screen_Width=1024
Screen_Height=768
BPP=32

If I wanted to change the BPP for example via a GUI, what would I need to do programming wise to change the value of the BPP field from 32 to say 64? I can design the GUI I would need but seem to be stumbling on how to make such a change via code.

Thanks and love this site!

Is This A Good Question/Topic? 0
  • +

Replies To: updating a .cfg file

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5629
  • View blog
  • Posts: 12,076
  • Joined: 02-June 10

Re: updating a .cfg file

Posted 02 January 2013 - 04:32 PM

a .cfg is just a text file with .cfg as the extension.

Read in the entire file storing all the values.
Make the changes in memory.
Write the entire file back out.

Being a text file you can't just change one part of it. You have to write the entire file.

excerpt from my new coder resources post:


Writing a text file is always one of the first things people want to do, in order to store data like high-scores, preferences and so on.
Writing a text file tutorial.
Reading a text file tutorial.
.Split()ing a string

Have you seen the 500+ MSDN Code Samples? They spent a lot of time creating samples and demos. It seems a shame to not use them.
Was This Post Helpful? 1
  • +
  • -

#3 CodeMonkey65  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 02-January 13

Re: updating a .cfg file

Posted 02 January 2013 - 04:35 PM

Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1