views:

510

answers:

4

Hello,

C# 2005

I am using a installer class as I need a custom action that will read in a xml config file.

So when the user double clicks the setup, there will be a config.xml file in the same folder. I would like to read in this config.xml file on install event. The folder will contain setup.exe and config.xml

However, it can't find the config.xml file as it is looking for it under C:\windows\system32. I found this out by using applicationstartup.path. However, the setup folder which contains the setup and config.xml is located on my desktop.

I thought it will look for it in the current location. Which would be the setup folder.

The difficulty is that my setup folder will be downloaded from the Internet and any user could download it and unzip it anywhere on their computer.

Here is my code snippet for the on install event.

Many thanks for any advice

protected override void OnAfterInstall(System.Collections.IDictionary savedState)
    {
        DataTable dt = new DataTable();
        MessageBox.Show(Application.StartupPath.ToString());
        dt.ReadXml("config.xml");

        MessageBox.Show(base.Context.Parameters["CAT_TargetDir"].ToString());
    }
+1  A: 

Assuming you're talking about an MSI, isn't that the OriginalDatabase property?

Si
+1  A: 

Supposing you're not mistyping CAT_TargetDir instead of TARGETDIR you can do the following work-around: set a CustomActionData and pass TARGETDIR as the argument to your Custom action. It's not the most elegant solution but it should work pretty easy.

da_m_n
A: 

Hello,

I am managed to solve this.

The answer was just to write a simple bat file that will do all the work for me. Then the bat file will call the setup and install the application.

Thanks,

robUK