Monthly Archives: January 2008

Raising an event in C#

Raising an event in C# is ridiculously complicated, but here goes.  This is based on MSDN “How to:  Implement Events in Your Class”. ITEM 1 Create a class for the event arguments. public class FactoryInfoEventArgs : EventArgs { private string mSource; public string Source { get { return mSource; } set { mSource = value; […]

Reading/Writing XML files

1.  XmlWriter – This is simple but tedious and error prone.  You can create an XmlWriter and use WriteStartElement, WriteElementString, and WriteEndElement to explictly write the XML statements. If writing to a file, set the XmlWriterSettings.Indent property to true.  Otherwise you don’t get any indents or carriage returns in the output file. XmlWriterSettings settings = new […]

Simple Database Tricks with SQL Server Express

Copy database from one server to another This is suprisingly easy.  On the source PC: In SQL Server Management Studio Express, detach the database Copy the .mdf and .log files for the database.  These are located in a path similar to:  “C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data” Attach the database again On the target PC: Copy the […]

The .NET Developer’s Guide to Windows Security by Keith Brown

Copyright 2005  I really like the way this book is laid out.  It is set up as 75 independent “items” of about 4 pages each.  Each item is a readable, self-contained chunk of information about some aspect of security.  So, the writing is great and the layout is great.  The content is probably great also, […]

ListBox DataSource property

The ListBox control has a property called “DataSource”.  You can set the DataSource to a list of items and voila!  they are all magically displayed in the listbox.  This initially seems very cool, but it turns out to only work in limited situations. List<MyObjectName> MyObjectList; listBox1.DataSource = MyObjectList; listBox1.DisplayMember = “SomePropertyName”; // property name from […]