Archive for the ‘ General ’ Category

Blogging Efforts

I have decided to start contributing to my companies Blog on Microsoft Technologies. They will require me too post more frequently.  So if my past blogging efforts have been beneficial to you keep an eye on to see what I have too say. I will likely post references to the post here as well.


Whether I get feedback or not I’m going to start using to post all the events I will be speaking at. You can find most of my past events here ( I will be posting all my upcoming events as they are finalized.  If you have been to any my talks please give feedback.

This site will make it easier for me to track my events.

Create application Shortcut in .Net the easy way

Have you ever needed to create an application shortcut on the fly in your .Net application? Well I have and this is what I did. The easiest way to create a shortcut is to create a url file which contains a reference to your file instead of a web address. A url file is basically like an ini file. To create a real desktop shortcut requires the use of a COM object, which for my case was not needed.

A url file is a plain text file with the “url” file extension. Below is an Example of the required content of a url file:

There are other options that can be added to the url file as well, but all you need to specify is the URL. Rather than using a url to a internet location you can create one for a file on your system by setting URL to file:///c:/Temp/ReferenceFile.txt. Example of a url file content with additional options to specify the icon:
URL = file:///c:/Temp/ReferenceFile.txt
IconIndex = 0
IconFile = C:\Temp\application.ico

Here is an example of how to create the url file in C# using .Net 2.0:
using System;
using System.IO;
using System.Text;

public static class Program {
  public static void Main() {

  private static void CreateDesktopShortcut() {
    String appName = "Application.exe";
    String appDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
    String shortcutName = "Application";
    String shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
    StringBuilder sb = new StringBuilder();

    sb.AppendLine(String.Format(@"URL=file:///{0}/{1}", appDirectory, appName).Replace(@"\", @"/"));

    File.WriteAllText(String.Format(@"{0}\{1}.url", shortcutPath, shortcutName), sb.ToString());