Tag Archives: microsoft

Windows 8 Developer’s Camp 2012 – Perth, Western Australia

Ok Windows 8 Developer’s Camp 2012 is coming soon to Perth Western Australia, it will be held at University of Western Australia. This event is free and it’s a full day event filled with lessons on  developing metro style applications for Windows 8. The event will be held  on the 16th June 2012 from 9:00am to 5:30pm Saturday. 

If any developer’s from Perth, is reading this blog and would like to go and meet up at the event send me a message on twitter @david_loo.

For further details of the event and registration in your local area go to the link below:

Windows 8 Developer’s Camp Registration

C#: DataTable to CSV

 

Recently I wrote a small program to allow me to connect to a SQL database and export a selected table to a CSV file. So I needed a method that can take in a DataTable and the delimiter character to use. The returned result is a string which can be save straight to a text file.

Below is the method in my program, you may copy, modify and use it in your own program.

I use a StringBuilder class to build my lines of comma separated values and then return it as a String type. Currently the code only format string values with double quotes inserted around the value and the rest is a straight output.

Continue reading

C#: How to get your computer and user name.

If you want to get your computer and user name from Windows in C# try this by using the WindowsIdentity class from System.Security.Principal namespace:

<span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.Linq;
<span style="color: blue">using </span>System.Text;
<span style="color: blue">using </span>System.Security.Principal;

<span style="color: blue">namespace </span>ConsoleApplication1
{
    <span style="color: blue">class </span><span style="color: #2b91af">Program
    </span>{
        <span style="color: blue">static void </span>Main(<span style="color: blue">string</span>[] args)
        {
            System.<span style="color: #2b91af">Console</span>.Out.WriteLine(<span style="color: #2b91af">WindowsIdentity</span>.GetCurrent().Name);
        }
    }
}