Resolved nini help needed

firefix

New member
Joined
Nov 7, 2009
Messages
1
Programming Experience
Beginner
If someone has experienced please help with the following:
I need to save path to image using nini (Nini: An uncommonly powerful .NET configuration library)
So everything works except the path from OpenFileDialog
The code is:

VB.NET:
Imports System.Diagnostics
Imports Nini.Config
Imports System.IO

Public Class CompanySetup
    '  Inherits System.Windows.Forms.Form
Public Shared fileBanner As String
Private sourc As IniConfigSource
Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click

        With bannerFile
            .CheckFileExists = True
            .ShowReadOnly = False
            .Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg"
            .FilterIndex = 2
            If .ShowDialog = DialogResult.OK Then
                bannerBox.Image = Image.FromFile(.FileName)
                fileBanner = bannerFile.FileName.ToString

            End If
        End With
    End Sub
     
      
sourc.Configs("General").Set("Imgpic", strimg)
     

sourc.Configs("General").Set("CoName", txtCoName.Text)
        sourc.Configs("General").Set("Imgpic", fileBanner)
        sourc.Configs("General").Set("Addr", txtAddr.Text)
        sourc.Configs("General").Set("Phone", txtPhone.Text)
        sourc.Configs("General").Set("Fax", txtFax.Text)
        sourc.Configs("General").Set("Email", txtEmail.Text)
        sourc.Configs("General").Set("Vat", txtVat.Text)
        sourc.Configs("General").Set("Btm1", txtBtm1.Text)
        sourc.Configs("General").Set("Btm2", txtBtm2.Text)
        sourc.Configs("General").Set("Btm3", txtBtm3.Text)
        sourc.Configs("General").Set("Btm4", txtBtm4.Text)


        sourc.Save()

Private Sub CompanySetup_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Load the configuration source file
        sourc = New IniConfigSource("dvinv.ini")
        'sourc.CaseSensitive = False

        ' Set the config to the Logging section of the INI file.
        Dim config As IConfig
        config = sourc.Configs("General")

        ' Load up some normal configuration values
        txtCoName.Text = config.Get("CoName")
        fileBanner = config.Get("Imgpic")
        '  MsgBox(config.Get("Imgpic"))

        Try
            bannerBox.Image = Image.FromFile(fileBanner)
        Catch ex As Exception
        End Try
        txtAddr.Text = config.Get("Addr")
        txtPhone.Text = config.Get("Phone")
        txtFax.Text = config.Get("Fax")
        txtEmail.Text = config.Get("Email")
        txtVat.Text = config.Get("Vat")
        txtBtm1.Text = config.Get("Btm1")
        txtBtm2.Text = config.Get("Btm2")
        txtBtm3.Text = config.Get("Btm3")
        txtBtm4.Text = config.Get("Btm4")



    End Sub
No key value Imgpic changes in .ini file!
Please help.
Resolved via IniFile class. It doesn't hate OpenFileDialog like Nini does.
 
Last edited:
Back
Top