Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

MSN Emoticons to GIF

4.29/5 (5 votes)
2 Nov 2009CPOL2 min read 32.9K   448  
Backup or save or convert MSN Messenger custom emoticons to GIF files

Introduction

Have you ever wanted to save custom emoticons from MSN to your hard drive?

MSNEmoticonsToGif allows you to browse all your MSN Messenger custom emoticons, and save them to your hard disk for backup or any other purpose.

Using the Program

After extracting and executing the program:

Image 1

  1. Enter your MSN address (Windows Live ID).
  2. Choose the folder path where you want the emoticons/pictures to be saved.
  3. Check overwrite if an emoticon with the same name already exists and you want it to be automatically overwritten.

Image 2

  1. Click Find.
  2. If custom emoticons are found, a message will be displayed showing that custom emoticons were found.
  3. The first emoticon will be displayed in the picture box.

Image 3

  1. Use the next and previous arrows to switch pictures.
  2. In the status bar, information about the selected emoticon/picture is displayed, its number, its size in bytes, and its width by height in pixels.

Image 4

  1. Click Save all to save all the emoticons to the previously selected folder.
  2. If you would like to save only one emoticon, right click the emoticon and click Save.
  3. Choose Save as... if you would like to save the emoticon to a folder of your choice.

Using the Code

First, we add the IO library:

C#
using System.IO;

Now, we have to find the path where the custom emoticons are stored.

By default, MSN Messenger stores all custom emoticons in the Local Settings\Application Data\Microsoft\Messenger\msn live ID\ObjectStore\CustomEmoticons folder, with a .dt2 file extension.

But since every computer can have a different Windows user account name, we need to use the following code to get the path for the Local Settings/Application data folder:

C#
string accountPath;
accountPath = System.Environment.GetFolderPath(
                 Environment.SpecialFolder.LocalApplicationData );

Let's assume that the MSN address is etienne@live.com, and then we add the rest of the path:

C#
string accountName = "etienne@live.com";
accountPath += "\\Microsoft\\Messenger\\";//"
accountPath += accountName;
accountPath += "\\ObjectStore\\CustomEmoticons";

We check if the custom emoticons folder exists; if not, it means there are no custom emoticons. Then, we will load the path of each file/emoticon and save it as a GIF file in a new folder.

C#
//Check if folder exist
if (Directory.Exists(accountPath))
{
    //Load all the .dt2 files' path into an array
    string []filenames = Directory.GetFiles(accountPath, "*.dt2");

    //Save the emoticons in C:\Emoticons\etienne@live.com
    string savePath = "C:\\Emoticons\\";//"
    savePath += accountName;

    //Check if the folder to save the emoticons/GIF Files exists
    //if not, create the folder
    try
    {
        if (!Directory.Exists(savePath))
        {
            Directory.CreateDirectory(savePath);
        }
    }
    catch (IOException ex) 
    {
        //Error Creating Folder
    }

    //Save Files As Gif with the name 1.gif, 2.gif, 3.gif ...
    int i = 0;
    bool overwrite = true;
    try
    {
        foreach (string filename in filenames)
        {
            //File.Copy(string sourceFile, string destinationFile, bool overwrite)
            File.Copy(filename, savePath + "\\e" + ++i + ".gif", overwrite);
        }
    }
    catch (IOException ex)
    {
        //Error saving files
    }
}
else
{
    //No custom emoticons found.
}

Conclusion

Although it might not be the fanciest program around, I wrote it so I can browse through my emoticons, backup and save the ones I like, and also use them as icons or pictures in my computer.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)