Home > DeveloperSection > Forums > How to create an internet shortcut with an icon in c#?
Jeet Verma
Jeet Verma

Total Post:110

Points:776
Posted on    January-31-2014 11:32 PM

 C# C# 
Ratings:


 1 Reply(s)
 3234  View(s)
Rate this:

I want to create an internet shortcut (url file) with a custom icon on the desktop. To create the shortcut, I currently use:

    private void CreateShortcut(string name, string url)

    {

        string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

        using (StreamWriter writer = new StreamWriter(deskDir + "\\" + name + ".url"))

        {

            writer.WriteLine("[InternetShortcut]");

            writer.WriteLine("URL=" + url);

            writer.Flush();

        }

    }

But this code does not set a custom icon. How would I set the icon?



Pravesh Singh

Total Post:411

Points:2881
Posted on    January-31-2014 11:44 PM

Hi Jeet,

Set IconIndex and IconFile parameters:

[InternetShortcut]

URL=<url>

IconIndex=0

IconFile=<path to custom icon icon file>


Don't want to miss updates? Please click the below button!

Follow MindStick