Free Electronic Book: Programming Windows Phone 7

You can get a free ebook, Programming Windows Phone 7, by Charles Petzold here:


How to Give Authenticated Users or Everyone Access to Your Share Programmatically

Another follow-up from my previous article, Programmatically Configuring Permissions on a Share, David B asked a question, how to share a folder to Everyone, instead of to a specific users. This article will answer that question, based on the code on my previous article. That is an interesting question, since ‘Everyone’ can be replaced with…


How to Programmatically Modify the IIS Virtual Directory

If you have more than a dozen web servers in a cluster with identical setting, and you need to update the virtual directory, it is much more convenient to write a simple program to update it. This example shows how to do it. In this case, this snippet will change the physical path of a…


C# 3.0 Automatic Property

C# introduces a number of syntactic sugar, including Automatic Property link. A question was asked, why is this useful, what is the advantage of this approach compared to exposing the field as public field? The advantage of the automatic property is that while you have a much cleaner code, you still have encapsulation, you can…


How to Add Command Line Support with Your .MSI

One of the requirements in building setups was to allow the Operations team to execute the .msi file from the command line. GUI is not for expert! 🙂 If you are familiar with Visual Studio setup, each of the UI element has a property, and you pass this property to your custom action, or use…


Writing Fast Code (Resources)

This article is intended to help me remember where can I find these resources, also kind of helpful should I need to forward this to someone. Hopefully, this post will be continuously updated. Managed code is very fast in allocating memory, the problem is if the applications allocated too many unnecessary objects. Keep your memory…


When Building Multi-Threaded Applications using ThreadPool, Make the Number of Worker Threads Configurable

Just a simple thought, when creating a multi-threaded applications, make the number of threads configurable. ThreadPool has this behavior that it will immediately set the minimum worker threads equal to the number of logical processors in your machine, and set the maximum to 250 per logical processor, well documented in msdn (.Net Framework 2.0 SP1)….


String.Split has High Cost on Performance

One application had a memory issue, it just consume too much resources. The application performed well, but it is very obvious when we saw the performance counters, something can be done to make it better. Reviewing the code did not reveal something significant, the code already allocated objects that are necessary. The code parses a…


How to Create Custom Event Log for Windows Service

When you created a Windows Service, you usually add a Service Installer to allow this service to be installed using InstallUtil or installing it programmatically like this post shows you. The service installer will create the Event Log for the service, and by default it is "Application", and the source is the name of your…


How to Get IIS Web Sites Information Programmatically

I needed to get the location of IIS log files on my servers, after doing a quick investigation, I am quite amazed on how much information are exposed via managed code. This snippet will return the name of the sites and the location of the log files. foreach (DirectoryEntry Site in new DirectoryEntry("IIS://" + System.Environment.MachineName…