Page 1 of 1

App.Ini vs Web.Config

Posted: Tue Jun 02, 2020 11:03 pm
by byron.hopp
In harbour winforms applications we seem to store specific information for our apps in the .ini file. On the web it seems it is stored in web.config. Does mod_harbour have a way to read and write from a web.config file as harbour does with .ini's?

Thanks,

Re: App.Ini vs Web.Config

Posted: Fri Jun 05, 2020 5:10 pm
by Carles
Hi,

I think you can write/read yiur file config like a usual file. And for example you can use memowrit/memoread for it

C.

Re: App.Ini vs Web.Config

Posted: Fri Jun 05, 2020 5:14 pm
by byron.hopp
Yes, thank you, good point. I was looking for a class that may make it easier like the oIni class that allows us to read and write to INI files.

Re: App.Ini vs Web.Config

Posted: Fri Jun 05, 2020 5:34 pm
by Carles
Byron,

You can do

Code: Select all

function main()

    local cIni      :=  hb_GetEnv( "PRGPATH" ) + '/myini.txt'
    local hIni  := {=>}
    
    hIni[ 'name' ] := 'Charly'
    hIni[ 'last' ] := time()
    hIni[ 'age'  ] := 52

    //  Save your ini
    memowrit( cIni, hb_jsonencode( hIni ) )
    
    //  Read your ini
    h := hb_jsondecode( memoread( cIni ))
    
    ? h[ 'name' ]
    ? h[ 'last' ]
    ? h[ 'age' ]


retu nil

Re: App.Ini vs Web.Config

Posted: Fri Jun 05, 2020 5:51 pm
by byron.hopp
Below is a minimal web.config example from Microsoft Support.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>

</system.web>
</configuration>