> Hello,
>
[quoted text clipped - 30 lines]
> B) All values are string in ConfigurationManager?
> C) It is possible in the direct way boolean, double, etc?
(Another Way to read/write configuration values)
http://geekswithblogs.net/akraus1/articles/64871.aspx
You can make it a Bool right out of the gate by using the example, and you
can call the examples by name anything you want, like ConfigData --
ConfigSettings.
And with in the Configdata.cs
[ConfigurationProperty("closeapplication")]
public bool CloseApplication {
get { return (bool)this["closeapplication"]; }
set{ this["closeapplication"] = value; }
}
Thomas Bauer - 10 Jan 2008 07:29 GMT
Hello,
> You can make it a Bool right out of the gate by using the example, and you
> can call the examples by name anything you want, like ConfigData --
[quoted text clipped - 10 lines]
>
> }
OK how?
With a assistent?
Regards Thomas
Error 1 The type "ConfigurationProperty" is not found. (Missing using
directive or assembly relation?)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace RFileCleaner
{
public partial class frmRFileCleaner : Form
{
string Directory;
bool CloseApplication;
Int32 DeleteFilesOlderThanDays;
[ConfigurationProperty( "CloseApplication" )]
public bool CloseApplication2
{
get { return (bool)this["CloseApplication"]; }
set { this["CloseApplication"] = value; }
}
public frmRFileCleaner( )
{
InitializeComponent();
//<add key="Directory" value="C:\_Database\" />
//<add key="CloseApplication" value="0" />
Directory =
System.Configuration.ConfigurationManager.AppSettings["Directory"];
string help =
System.Configuration.ConfigurationManager.AppSettings["CloseApplication"];
Int32 ret = Convert.ToInt32( help );
if ( ret == 0 )
CloseApplication = false;
else
CloseApplication = true;
help =
System.Configuration.ConfigurationManager.AppSettings["DeleteFilesOlderThanDays"];
DeleteFilesOlderThanDays = Convert.ToInt32( help );
}