VB6: Create ini file on the fly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TUSSFC
    New Member
    • Apr 2009
    • 2

    VB6: Create ini file on the fly

    My VB6 application needs the ability to create custom "config" files on the fly.

    I.e. form field values need to be saved to this config file for later use.

    I've found plenty of code for reading/writing to INI files which seems to meet my needs in terms of saving the custom configs.

    However ... the INI file already needs to exist for this to work.

    How can I create a new blank INI file on the fly?

    TIA.

    Code, eg:

    ' get filepath
    strFilePath = App.Path & "\config\" & strReportName & ".ini"

    ' check if ini file exists already
    If Not (Dir(strFilePat h) <> "") Then
    'create ini file

    End If
  • TUSSFC
    New Member
    • Apr 2009
    • 2

    #2
    Doh ... I assumed you couldn't use FSO to create INI files, but you can.

    Set objFSo = CreateObject("S cripting.FileSy stemObject")
    Set objFileNew = objFSo.CreateTe xtFile(App.Path & "\config\" & strReportName & ".ini", ForWriting)
    objFileNew.Clos e

    Comment

    Working...