473,383 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

using isolated storage to save boolean values in .net

I am trying to save some boolean values from checkboxes using isolated
storage. I am able to do strings and integers without a problem but I
can't work out how to save boolean values without seeing the error
message below:

'Additional information: Argument 'Prompt' cannot be converted to type
'String'

The error message is displayed at this line of code in the form load
event.

'Dim isfs1 As IsolatedStorageFileStream = New
IsolatedStorageFileStream("frmGSCCServerConfig.xml ", FileMode.Open,
FileAccess.Read, isf)'
The full code listing is below:

Public Class frmGSCCServerConfigurationClass
Public EnableJobsIntegration, ForceFixes As Boolean
End Class
Imports System.IO
Imports System.IO.IsolatedStorage
Imports System.Xml
Imports System.Xml.Serialization

Public Class frmGSCCServerConfig
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnSave.Click
Try
'get the isolated store for this assembly
Dim isf As IsolatedStorageFile =
IsolatedStorageFile.GetUserStoreForAssembly()

'create or truncate the settings file
'this will ensure that only the object we're
'saving right now will be in the file

Dim isfs1 As IsolatedStorageFileStream = New
IsolatedStorageFileStream("frmGSCCServerConfig.xml ", FileMode.Create,
FileAccess.Write, isf)

'Construct an object and tell it about the form
Dim fs As frmGSCCServerConfigurationClass = New
frmGSCCServerConfigurationClass
fs.EnableJobsIntegration =
Me.chkEnableJobsIntegration.Checked
fs.ForceFixes = Me.chkForceFixes.Checked

'serialize the object to the file
Dim xs As XmlSerializer = New
XmlSerializer(GetType(frmGSCCServerConfigurationCl ass))
xs.Serialize(isfs1, fs)
isfs1.Close()
Catch ex As Exception
MsgBox(ex)
'if setting can't be saved,next run will just use the
'form defaults
End Try
End Sub

Private Sub frmGSCCServerConfig_Load(ByVal sender As Object, ByVal
e As System.EventArgs) Handles MyBase.Load
Try
'get the isolated store for this assembly
Dim isf As IsolatedStorageFile =
IsolatedStorageFile.GetUserStoreForAssembly()

'Open the settings file
Dim isfs1 As IsolatedStorageFileStream = New
IsolatedStorageFileStream("frmGSCCServerConfig.xml ", FileMode.Open,
FileAccess.Read, isf)

'Deserialize the XML to an object
Dim fs As frmGSCCServerConfigurationClass = New
frmGSCCServerConfigurationClass
Dim xtr As XmlTextReader = New XmlTextReader(isfs1)
Dim xs As XmlSerializer = New
XmlSerializer(GetType(frmGSCCServerConfigurationCl ass))
fs = CType(xs.Deserialize(xtr),
frmGSCCServerConfigurationClass)

'And apply the settings to the form
chkEnableJobsIntegration.Checked =
fs.EnableJobsIntegration.Equals(Boolean.TrueString )
chkForceFixes.Checked =
fs.ForceFixes.Equals(Boolean.TrueString)

'Clean up
isfs1.Close()
Catch ex As Exception
'no file found. Just run with the existing settings
MsgBox(ex)
End Try
End Sub

End Class


I'd be greatful for any suggestions.

Thank in advance
Robert
Nov 21 '05 #1
0 1259

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jody Gelowitz | last post by:
Exactly what is the size limit of Isolated Storage in the Internet permission set? I have a document indicating it is 10MB (http://msdn.microsoft.com/msdnmag/issues/02/07/NetSmartClients/) ...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
3
by: gani | last post by:
hi, how to get the fullpath of created IsolatedStorage directory. thanks. -- gani
1
by: malcolm | last post by:
Hello, We use several user controls and derived custom controls. Some of which actually hit the database at design time to show data (such as filling a list box, etc...) Our c# client server...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Group, After a long week end I am back again. Its nice and refreshing after a short vacation so lets get started with .NET once again. Today we will discuss about Isolated Storage. This is...
12
by: shawnn | last post by:
Hello, By default, when you create an App.config file it gets named as MyApp.exe.config after build. I don't like this name and would rather have the file named MyApp.config, the .exe.config...
2
by: Bob | last post by:
Using VS2005 andf VB.NET how can you store a faile in protected storage. How can you retrieve and open a file from protected storage? Can anyone point me to snippets of code doing this? Thanks for...
1
by: C#Coder | last post by:
I need to create an Isolated Storage File for my assembly with machine level scope. I have used the 'GetMachineStoreForAssembly' method to do this and this creates the Isolated Storage File...
2
by: Andrus | last post by:
WinForms MDI application stores user preferences (form position, sizes, query params etc) in isolated storage. I want to offer user menu selection "Restore defaults" which deletes all those...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.