Question helping the .ini file?

Rainny

Member
Joined
Jun 9, 2008
Messages
16
Programming Experience
Beginner
Hi, everyone. I have some question need get the helping from you all.
My question is as the following.

Lets say that I have many folders in the particular folder, but there are two folder which I no need to check the content inside.
How i go write the .ini file for excluding from the two folder?
and how is the vb.net coding to read the .ini file?

Thanks a lot for you all helping.

Really thank you.
 
Before anyone could answer your question, we would need to know more:

What are you using the .ini file for? (Besides, I would suggest using an XML based file instead. .ini files are so 90's).

You say you want to "check the contents" of two folders: What are you checking for, what will you do with the result, etc...
 
The purpose i using the .ini file because I want to store the specify directory for the files. So, next time if i want to change the directory,
i just need to modify the .ini file and no need go through the vb project file. Besides, there are two folders which inside that particular directory,
I don't want to check through the two folders. So, how should i write the .ini file and also using vb.net write the coding for excluded the two folders?
Thanks a lot for helping.
 
We use My.Settings now, not ini files. The framework can and will automatically read the settings from the YourApp.Config file that is made. Take a look in Project Properties, for "Settings"
 
If you still wanna use an ini-File, you'll have to go with the API, like this:
VB.NET:
    Friend Class SafeNativeMethods
        <Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True)> _
        Friend Shared Function GetPrivateProfileString(ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As System.Text.StringBuilder, ByVal nSize As Integer, ByVal lpFileName As String) As Int32
        End Function
        <Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True)> _
        Friend Shared Function WritePrivateProfileString(ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32
        End Function
        Private Sub New()
        End Sub
    End Class

Then you can read/Write settings like this:
VB.NET:
'read
Dim result As New System.Text.StringBuilder(255)
SafeNativeMethods.GetPrivateProfileString(section, keyName, vbNullString, result, result.Capacity, iniFile)

'Write
SafeNativeMethods.WritePrivateProfileString(section, keyName, keyValue, iniFile)

Bobby
 
Back
Top