|
I guess this might help and I am trying to read the article.
However, the code in the article looks bit complicated. Can you (someone) maybe give me a simple example of reading/writing a couple of settings?
like nick : real name?
thanks a lot lot lot!
|
|
|
|
|
The .config file is just an XML file, so use the System.Xml namespace elements to append/insert/delete your settings. Note that this will not update your configuration options while the process is running. For information on how to do that, search the comments for this forum for keywords like AppDomainSetup because I've already covered how to do this a couple times. Of course, you could always update your settings in the running, cached instance if you provide an instance property for your configuration section object (which the IConfigurationSectionHandler implementation creates) and update your UI accordingly.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Look at XML serialization. You can create an xml file that contains your app settings. You would simply 1. open a file stream 2. create xml formatter 3. serialize the settings you choose to the xml file.
Take a look at serialization. You could use the .config file but this is read only, therefore you cannot create a user interface to modify it.
|
|
|
|
|
And if the config file contained other stuff not for his section? This would NOT be a good idea because the other IConfigurationSectionHandler implementations provided in the .NET BCL do not use XML serialization. XML Serialization would wipe out the file and create a new one (based on your stream preferences).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
For a simple solution take a look at my Profile article[^].
Regards,
Alvaro
He who laughs last, thinks slowest.
|
|
|
|
|
How can i create a new datatable in a database ?
We have a connection and a dataadaptor .
I mean programically.
Regards' Amir Jalaly
life is tow days'
one is paid for love someone '
and one day is paid for hate him'
|
|
|
|
|
|
I want to convert this code from vb.net to c#.net:
Declare Function ExitWindowEx Lib "User32" (Byval l as long ,Byval s as long ) as long or this:
Declare Function FormatMessage Lib "kernel32" Alias _<br />
"FormatMessageA" (ByVal dwFlags As Int32, ByVal lpSource As Int32, _<br />
ByVal dwMessageId As Int32, ByVal dwLanguageId As Int32, _<br />
ByVal lpBuffer As StringBuilder, ByVal nSize As Int32, ByVal Arguments As Int32) _<br />
As Int32
what is equal for Declare and lib in C#?
Regards'Amir Jalaly
life is tow days'
one is paid for love someone '
and one day is paid for hate him'
|
|
|
|
|
Amirjalaly wrote:
what is equal for Declare and lib in C#?
Check the documentation for DllImportAttribute Class[^].
- Nick Parker My Blog
Last time I checked, all programmers have selective ignorance. I know nothing about 3D graphics. I know a lot about COM. VB gets under people's skin because one can be ignorant of computer architecture and ASM and still get a lot done. - Don Box
|
|
|
|
|
Hello,
I'm going to use C struct in C#, but I'm not sure how to convert the struct to C# structure?
struct HeaderStruct
{
void *FileHeader;
void *Info;
char *input;
}
could anybody help me? Thank you~~
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public struct HeaderStruct
{
public IntPtr FileHeader;
public IntPtr Info;
public string input;
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Use a custom ListViewItem or something with the properties you want, and in the handler for the ListView.SelectedIndexChanged event, set the PropertyGrid.SelectedObject to your custum ListViewItem . You should read about the classes in the System.ComponentModel namespace for ways to provide custom TypeConverter s and UITypeEditor s for those properties if you require it.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi all!
Possible do toolbar flat as in IE6.0?
I know that in VC6.0 this was not a problem.
But in VC.NET, I can not do this.
|
|
|
|
|
ToolBar.Appearance = ToolBarAppearance.Flat
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Many thanks.
You me much helped.
|
|
|
|
|
Hi Guys!
we know that there is a way to handle custom exceptions in
asp dot net by specify the error page.
is there any way to do the same in csharp windows form.
i.e custom windows form.
i don't want to write try/catch block in my programm
in all places.i just want to write it once where it can handle all the program exception. is there a way.
i want to write only one try/catch block that can handle all the exceptions of the whole applications(windows Application), which off-course may contains multiple windows forms
Ali Khan
|
|
|
|
|
AppDomain.UnhandledException
You can get the current AppDomain with AppDomain.Current .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I've been battling this too long and wanted to see if someone can help.
I've created a directory on our Win2k Server. The directory automatically assumes I want to inherit the parents (i.e. the box under the security tab that says "Allow inheritable permissions from parent to propagate to this object"). Ok, that's fine, but I would like to turn that option off through my C# script. I can add ACE's and modify everything at the ACE level, but haven't found anything that states how to change this option.
I'm sure it is simple, but I haven't been able to figure it out.
Thanks!
|
|
|
|
|
I need a way to be able to detect when ac power to my computer is not available. My cpu is on an UPS and system power management does not catch this event if i unplug the UPS and my system runs on battery. I read the documentation for the system power management class and it will detect an ac to battery power event for a system (internal battery) battery. Does anyone know of a way i can detect when power is coming from a battery in the UPS? Thanks in advance!
|
|
|
|
|
Well, to the computer it's still just AC power. But AFAIK many UPS power supplies have some sort of serial-port or USB connection, and drivers that tell the computer when it's on UPS battery power.
I'm not an expert on this by any far stretch, though, so I can't really answer you question completely.
|
|
|
|
|
jdunlap's correct. Unless the UPS is connected to your computer by something other than your computer's power cord, there's no way for your computer to know.
Old UPS's used serial ports, and a lot of the newer ones use USB, but in either case the UPS has to "tell" the computer. Take a look at the documentation for your UPS.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
I am trying to add an arraylist to a datatable. The ArrayList contains a struct and the the struct basically holds several object variables. I use a foreach statement to loop through the arraylist and add the data to a datarow then add the datarow to a datatable. However, when I try to add the second datarow I get an error message saying 'This row already belongs to this table'. Even though I know the data has changed the it is a completely different row. I am including my code snippet, any suggestions is appreciated:
r = DataSet.Tables["TradeOrderFills"].NewRow();
theData = (ArrayList) oFills.GetByIndex(0);
Console.WriteLine("theData count "+theData.Count);
foreach(TradeData td in theData)
{
Console.WriteLine("Adding Row to DataTable");
Console.WriteLine(td.ticker);
r["preTicker"] = (string)td.ticker;
Console.WriteLine("column value "+r["preTicker"]);
Console.WriteLine(td.transactionType);
r["preTransType"] = (string)td.transactionType;
Console.WriteLine("column value "+r["preTransType"]);
r["preOrderTime"] = (string)td.orderTime;
r["prePrice"] = Convert.ToSingle(td.price);
r["preQ"] = Convert.ToSingle(td.fillQ);
r["preAccount"] = (string)td.account;
r["preBroker"] = (string)td.broker;
r["preStatus"] = (string)td.status;
DataSet.Tables["TradeOrderFills"].Rows.Add(r); //THIS IS WHERE THE ERROR OCCURS ON THE 2nd ITERATION
Console.WriteLine("Number of Rows "+DataSet.Tables["TradeOrderFills"].Rows.Count);
}
|
|
|
|
|
Move your first line:
r = DataSet.Tables["TradeOrderFills"].NewRow();
inside the foreach loop.
What you were doing is inserting the same physical row each time, but just changing the data it contained. You need to create a new physical row on each iteration.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
How do I create a new GUID using C#?
I tried this but it shows up as 00000000-0000-0000-0000-000000000000.
Guid guid = new Guid();
Console.WriteLine( guid );
|
|
|
|
|
Try the static method Guid.NewGuid()
You can find more information on MSDN[^]
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|