I have been googling for quite a while but I just can't seem to find a precise answer to my question.

I'm able to create the setup project and the installation works fine. Included in my application is a .MDB file. What I would like to do, during the installation, is check to see if the .MDB already exists and prompt the user to either overwrite the database file or leave it.

Has anyone done this exact same thing before?

I'm using VS 2008

Thanks,

Tim

yeah for these things you have to include a installer class into your setup project and put your code into the install event.

yeah for these things you have to include a installer class into your setup project and put your code into the install event.

Ok, thanks. I'll investigate this approach then. Have you done this before?

Thanks,

Tim

yes i have done something similar before but in the uninstall event. sample code is below.

Imports System.ComponentModel
Imports System.Configuration.Install

Public Class Installer1

    Private Function RecurseDir(ByVal path As String) As Boolean
        'recurse down thru each folder
        For Each f In IO.Directory.GetFiles(path)
            Try
                If f = Form1.xmlfile AndAlso IO.File.ReadAllBytes(Form1.xmlfile).Length > 150 Then
                    Continue For
                End If
                IO.File.Delete(f)
            Catch ex As Exception
                Continue For
            End Try
        Next

        For Each s As String In IO.Directory.GetDirectories(path)
            RecurseDir(s)
            IO.Directory.Delete(s, True)
        Next

        Return True
    End Function

    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub

    Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
        MyBase.Uninstall(savedState)
        Shell("REGSVR32.EXE /u /s VBMySQLDirect.dll")

        RecurseDir(My.Application.Info.DirectoryPath)
    End Sub

    Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        MyBase.Install(stateSaver)
        Shell("REGSVR32.EXE /s VBMySQLDirect.dll")
    End Sub

 
    Private Sub Installer1_AfterInstall(ByVal sender As Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles Me.AfterInstall
        My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\" & My.Application.Info.CompanyName, "Login", My.Computer.Name.GetHashCode)
    End Sub
End Class

Thanks! That code has definately helped me out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.