Click here to Skip to main content
13,862,802 members
Click here to Skip to main content
Add your own
alternative version


56 bookmarked
Posted 6 Jan 2010
Licenced CPOL

Remove Skype Chat History for Single Contact

, 17 Feb 2013
Rate this:
Please Sign up or sign in to vote.
A small C# utility to clear a single contact chat history, since Skype by default only deletes full chat history.


I wanted to clear the Skype chat history for a single user, but Skype only allows you to clear the complete chat history, not a single user's contact history.

I searched for 3rd party tools on the net but nothing worked for me on Windows 7 / Skype 4.1

At the beginning, I knew nothing about how Skype stored chat history and just entered my username and password to login and chat with friends.

After spending a few hours asking Google many questions, I found that Skype was using the following SQLite database to store its messages.

System Drive:\<Current User’s application data folder>/Skype/<Skype username>/main.db

I tried to read it with SQLitespy, but it was a pain to find and clear messages each time. Then, decided to develop a small C# utility to clear a single contact chat history.

Using the Code

First of all, I had to find a method to deal with an SQLite database file using C#. This is where the System.Data.SQLite plays a role in my application. You may download it from

Reference System.Data.SQLite.dll (Located in C:\Program Files\SQLite.NET\bin\System.Data.SQLite.dll) to allow C# to deal with the SQLite database file.

Once I knew I was going to dirty my hands with development, I wanted to find the Skype username(s) to reach to the database file. In System Drive:\<Current User’s application data folder>/Skype/ folder, Other than Skype user folder(s), there are 3 folders that Skype use for its operations, “Content”, “My Skype received files” and “Pictures”. I wrote codes to read subfolders and filter-out those 3 Skype standard folders.

String sDirName = Environment.GetEnvironmentVariable("APPDATA") + @"\Skype";
String [] folders = Directory.GetDirectories(sDirName);
String[] names = new String[folders.Length-3];

            foreach (String fname in folders){
                String folder = fname.Replace(Environment.GetEnvironmentVariable("APPDATA") +
                    @"\Skype\", "");
                if (folder != "Content" && folder != "My Skype Received Files" && 
                    folder != "Pictures")

The Usernamecb variable will be used to populate the dropdown box in the UI.

Based on the selected username we can reach the Skype message database (main.db) and read chat participants. Chat messages are stored in the "Messages" table.

The following code reads the database and fetches chat participnts (Contacts) who has messages in it.

database = Environment.GetEnvironmentVariable("APPDATA") + @"\Skype\" + SkypeUserName + 
SQLiteConnection sqlite = new SQLiteConnection("data source=" + database);
SQLiteDataAdapter ad;
DataTable dt = new DataTable();

SQLiteCommand cmd;


cmd = sqlite.CreateCommand();
cmd.CommandText = "select DISTINCT dialog_partner from Messages";
ad = new SQLiteDataAdapter(cmd);
ad.Fill(dt); //execute command
participants.DataSource = dt;
participants.ValueMember = "dialog_partner";

Where participants is a dropdown box in UI that displays chat participants.

When the user selects the participant from the dropdown box, the following SQL command deletes all messages for a selected participant from the database.

cmd = sqlite.CreateCommand();
cmd.CommandText = "delete from Messages Where dialog_partner = '" + participant + "'";
ad = new SQLiteDataAdapter(cmd);
ad.Fill(dt); //execute command

Then I realized that the database file is been locked while Skype is running. Therefore, I added code to terminate the Skype process when the program starts running, and starts up Skype again when the program closes.

// Terminate Skype
foreach (Process p in Process.GetProcesses(Environment.MachineName))
                if (p.ProcessName.Equals("Skype"))
//Start Skype when the programe is exiting
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            // open Skype again
            String program = Environment.GetEnvironmentVariable("ProgramFiles");

                System.Diagnostics.ProcessStartInfo psi =
                new System.Diagnostics.ProcessStartInfo(program + @"\Skype\Phone\Skype.exe");
            catch (Exception ex){}

When all the code comes together, it is a nice and painless tool for clearing a single user's chat history. 

Revision (2013/02/18) 

1. Updated utility to working with Skype 5.1 and later folder structure while searching skype user accounts

2. Application will automatically remove conversation from recent conversation tab

3. Published setup files for both 32bit and 64 systems 



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


About the Author

Web Developer
Sri Lanka Sri Lanka
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionWhen I try to open it says that the skype is running Pin
Member 1206143415-Oct-15 7:19
memberMember 1206143415-Oct-15 7:19 
AnswerRe: When I try to open it says that the skype is running Pin
Member 128267161-Nov-16 3:18
memberMember 128267161-Nov-16 3:18 
QuestionKeep saying that Skype is still running & messages on Skype server Pin
Member 1177315217-Jun-15 6:44
memberMember 1177315217-Jun-15 6:44 
AnswerRe: Keep saying that Skype is still running & messages on Skype server Pin
Member 1177315217-Jun-15 8:48
memberMember 1177315217-Jun-15 8:48 
Questionthere is a problem.... Pin
Member 115916408-Apr-15 10:51
memberMember 115916408-Apr-15 10:51 
AnswerRe: there is a problem.... Pin
Wombaticus22-Aug-15 23:02
memberWombaticus22-Aug-15 23:02 
QuestionWon't delete anything Pin
Aroman0072-Jan-15 9:48
memberAroman0072-Jan-15 9:48 
BugException (Windows 8) Pin
alexandis16-Jul-14 9:06
memberalexandis16-Jul-14 9:06 
QuestionFix for Deleting completely Pin
dinhthuan_bk8819-May-14 19:42
memberdinhthuan_bk8819-May-14 19:42 
Questioncant run Pin
hubertsk14-Apr-14 10:10
memberhubertsk14-Apr-14 10:10 
QuestionRe: cant run Pin
hubertsk22-Apr-14 2:35
memberhubertsk22-Apr-14 2:35 
Questioncan't run Pin
McClausky8-May-13 4:25
memberMcClausky8-May-13 4:25 
BugDoesn't delete ALL messages Pin
RaMMicHaeL28-Apr-13 5:47
memberRaMMicHaeL28-Apr-13 5:47 
QuestionSelecting a date range still erased ENTIRE persons history Pin
Member 964919527-Apr-13 4:42
memberMember 964919527-Apr-13 4:42 
GeneralMy vote of 4 Pin
pakssg15-Apr-13 0:27
memberpakssg15-Apr-13 0:27 
Questionhelp .NET ERROR Pin
Member 98835866-Mar-13 23:04
memberMember 98835866-Mar-13 23:04 
AnswerRe: help .NET ERROR Pin
Sergey Kasatikoff11-Mar-13 19:55
memberSergey Kasatikoff11-Mar-13 19:55 
Questiondate interval Pin
apabox22-Feb-13 9:02
memberapabox22-Feb-13 9:02 
GeneralMy vote of 2 Pin
lankymart13-Feb-13 4:48
professionallankymart13-Feb-13 4:48 
GeneralRe: My vote of 2 Pin
PavloD14-Feb-13 22:59
memberPavloD14-Feb-13 22:59 
GeneralRe: My vote of 2 Pin
lkgamage18-Feb-13 3:53
memberlkgamage18-Feb-13 3:53 
GeneralRe: My vote of 2 Pin
PavloD18-Feb-13 5:22
memberPavloD18-Feb-13 5:22 
GeneralRe: My vote of 2 Pin
lkgamage18-Feb-13 5:42
memberlkgamage18-Feb-13 5:42 
GeneralRe: My vote of 2 Pin
PavloD19-Feb-13 4:41
memberPavloD19-Feb-13 4:41 
QuestionWorks like a Charm Pin
juan luis vera16-Jan-13 14:43
memberjuan luis vera16-Jan-13 14:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190214.1 | Last Updated 18 Feb 2013
Article Copyright 2010 by lkgamage
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid