From what I've read, the registry is still your best option (though not the
..NET way).
check out this month MSDN magazine's "User Preferences" for some other
ideas:
http://msdn.microsoft.com/msdnmag/is...7/default.aspx
A quick and dirty way is to create a simple class with your user's settings
and serialize it to their profile folder on disk. Here is the code I having
been toying around with:
<Serializable()> _
Public Class UserSettings
Private _username As String
Public Property UserName() As String
Get
If _username = Nothing Then
Return CurrentUser()
Else
Return _username.ToLower
End If
End Get
Set(ByVal Value As String)
_username = Value.ToLower
End Set
End Property
End Class
Imports System.Runtime.Serialization.Formatters.Binary
Public Class UserSettingsDB
Private Sub New()
End Sub
Public Shared Function LoadSettings() As UserSettings
Dim mySettings As New UserSettings
Dim s As String =
Environment.GetFolderPath(System.Environment.Speci alFolder.ApplicationData)
s &= "\myappname\myappname.bin"
If File.Exists(s) Then
Dim streamOut As FileStream
Try
Dim formatter As New BinaryFormatter
streamOut = New FileStream(s, FileMode.Open,
FileAccess.Read)
mySettings = CType(formatter.Deserialize(streamOut),
UserSettings)
Catch
Finally
streamOut.Close()
End Try
End If
Return mySettings
End Function
Public Shared Sub SaveSettings(ByVal mySettings As UserSettings)
Dim s As String =
Environment.GetFolderPath(System.Environment.Speci alFolder.ApplicationData)
s &= "\myappname"
If Not Directory.Exists(s) Then
Directory.CreateDirectory(s)
End If
s &= "\myappname.bin"
Dim formatter As New BinaryFormatter
Dim streamIn As New FileStream(s, FileMode.Create,
FileAccess.Write)
formatter.Serialize(streamIn, mySettings)
streamIn.Close()
End Sub
End Class
HTH,
Greg
"Woody Splawn" <no****@splawns.com> wrote in message
news:ev**************@TK2MSFTNGP12.phx.gbl...
In the tool I used to use I would write certain things to a .ini file in a
users private directory from time to time. For example, when the
application was started, a certain section of that .ini file is checked so
that the application will start in a way that is unique to the users
machine. This is a non windows app.
I see that it is not convenient to do the same in VB.net. Tools for
writing and reading from a .ini file are not good. It has occurred to me,
however, that I might just as easily make use of writing that data to an xml file
and get the same result.
Is anyone else doing it this way?