Tuesday, January 23, 2007

C# : XML in a C# string

Note: "Left quote" replaced by #, "Right quote" replaced by ^

How do you do this? It has quotes, slashes etc. e.g.

string zzz = "#employees xsi="http://www.w3.org/2001/XMLSchema-instance"^#employee-record^#employee-id^00001#/EMPLOYEE-ID^#employee-from^01 10 2006#/EMPLOYEE-FROM^#employee-to^01 11 2006#/EMPLOYEE-TO^#employee^#employee-id^00001#/EMPLOYEE-ID^#employee-name^Washington#/EMPLOYEE-NAME^#employee-firstname^George#/EMPLOYEE-FIRSTNAME^#employee-dob^01 01 1930#/EMPLOYEE-DOB^#/employee^#/EMPLOYEE-RECORD^#/employees^";

won't compile.

You could put a "@" in front to make it a verbatim string literal but it still won't compile.

The trick is to make each quote (") a double quote ("") e.g.

string zzz = @"#employees xsi=""^#employee-record^#employee-id^00001#/EMPLOYEE-ID^#employee-from^01 10 2006#/EMPLOYEE-FROM^#employee-to^01 11 2006#/EMPLOYEE-TO^#employee^#employee-id^00001#/EMPLOYEE-ID^#employee-name^Washington#/EMPLOYEE-NAME^#employee-firstname^George#/EMPLOYEE-FIRSTNAME^#employee-dob^01 01 1930#/EMPLOYEE-DOB^#/employee^#/EMPLOYEE-RECORD^#/employees^";

which does compile.

Enjoy!

Thursday, January 11, 2007

Windows XP : cisvc.exe hogs the hard drive

My PC randomly just sat there with the hard disk light on but I wasn't doing anything - plus it was dog-slow.

Using the excellent Process Explorer, I discovered that the "cisvc.exe" program was the cause of the problem. This is part of indexing services.

My first solution was simply to suspend this via Process Explorer. (Right click on cisvc.exe). This helped but I had to do it every time on start-up.

So I googled and found one possible solution:

My Computer - right click on the C: drive - Properties - uncheck "Allow Indexing Service to index this disk for fast file searching" in the General tab.

This helped but the problem still remained.

Then I found another, better solution:

Control panel - Administrative Tools - Computer Management - expand "Services and Applications" - right-click on "Indexing Service" - "All Tasks -> Tune Performance". Then decide what level you want.

Enjoy!