Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. .INI file usage in C#

.INI file usage in C#

Scheduled Pinned Locked Moved C#
csharpcomwindows-adminhelpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darryl Borden
    wrote on last edited by
    #1

    Is there support for using .ini files in C#? I can't seem to find it anywhere. Is there a substitute for this (I don't want to use the registry)? Thanks for your help! dpb Darryl Borden Principal IT Analyst darryl.borden@elpaso.com

    N K 2 Replies Last reply
    0
    • D Darryl Borden

      Is there support for using .ini files in C#? I can't seem to find it anywhere. Is there a substitute for this (I don't want to use the registry)? Thanks for your help! dpb Darryl Borden Principal IT Analyst darryl.borden@elpaso.com

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Darryl Borden wrote: Is there a substitute for this (I don't want to use the registry)? How about just using an XML file, I believe this is the "way" some apps are going now because it is so easy to work with them inside the Framework. Nick Parker
      May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


      A 1 Reply Last reply
      0
      • N Nick Parker

        Darryl Borden wrote: Is there a substitute for this (I don't want to use the registry)? How about just using an XML file, I believe this is the "way" some apps are going now because it is so easy to work with them inside the Framework. Nick Parker
        May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Can you show me an example how to read\write data to a xml file?

        N 1 Reply Last reply
        0
        • D Darryl Borden

          Is there support for using .ini files in C#? I can't seem to find it anywhere. Is there a substitute for this (I don't want to use the registry)? Thanks for your help! dpb Darryl Borden Principal IT Analyst darryl.borden@elpaso.com

          K Offline
          K Offline
          Karavaev Denis
          wrote on last edited by
          #4

          Try to use this code in your app. //////////////////////////////////////////////////// public class IniFile { public string path; [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section,string key,string val,string filePath); [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section,string key,string def,StringBuilder retVal,int size,string filePath); public IniFile(string INIPath) { path = INIPath; } public void IniWriteValue(string Section,string Key,string Value) { WritePrivateProfileString(Section,Key,Value,this.path); } public string IniReadValue(string Section,string Key) { StringBuilder temp = new StringBuilder(255); int i = GetPrivateProfileString(Section,Key,"",temp,255,this.path); return temp.ToString(); } } ===================== http://wasp.elcat.kg

          1 Reply Last reply
          0
          • A Anonymous

            Can you show me an example how to read\write data to a xml file?

            N Offline
            N Offline
            Nick Parker
            wrote on last edited by
            #5

            Here is an article that may help: Convert INI file to XML[^] Nick Parker
            May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups