Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating folders during my installation

VB
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        MyBase.Install(stateSaver)
        InstallDir = Me.Context.Parameters("dir")
       
        Try
            Directory.CreateDirectory(folder1)
            Directory.CreateDirectory(folder2)
           
            File.Create(folder1+ "\test1.txt")
            File.Create(folder2+ "\test2.txt")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub


VB
Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
        MyBase.Uninstall(savedState)

End Sub

I am using this code for uninstalltion but unfortuantely it is not deleting the folders and files.
how do i do i delete the files.

Regards
SK
Posted
Updated 19-Jun-12 1:52am
v3

1 solution

I don't think that this is unfortunate. It's just that you haven't handled it.

You have to use Custom Actions for that:
1.Add a new library ("CustomActions") to the setup project
2.Add => New Item => Installer class
3.Switch to code view and override the Uninstall method

C#
public override void Uninstall(IDictionary savedState)
{
    base.Uninstall(savedState);

    // Delete folder here.
}


1.Add the project output (Primary Output) of the CustomActions project to the setup project.
2.Right click your setup project and click View => Custom Actions
3.Rigth click uninstall => Add Custom Action => Application Folder => Primary Output of CustomActions
 
Share this answer
 
Comments
oppai_kamu 19-Jun-12 8:09am    
Thank you for the reply
I have
1.added a Installer class to the project.
2.Install method is overwritten as shown above.
3.Uninstall method is written as below
MyBase.Uninstall(savedState)
InstallDir = Me.Context.Parameters("dir")
Try
Directory.Delete(folder1)
Directory.Delete(folder2)
Catch ex As Exception
MsgBox(ex.Message)
End Try
4.to custom actions i have added primary output by right clicking on uninstall.

Am i am missing something?
i am uninstalling through Add/Remove in the control Panle
please advice.
Prasad_Kulkarni 19-Jun-12 8:21am    
Five!!!
Manas Bhardwaj 19-Jun-12 8:25am    
thx!
VJ Reddy 20-Jun-12 22:38pm    
Good answer. 5!
Manas Bhardwaj 21-Jun-12 3:15am    
thx!

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900