Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to find the directory path for msi during installation

How to find the directory path for msi during installation

Scheduled Pinned Locked Moved C#
questionhelptutorial
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honeyashu
    wrote on last edited by
    #1

    Hi, I needed to find the path of the MSI file through which i am installing the s/w.I needed to check certain file's path during installation(when Installer class is called ... How can i get the path of the msi file from where the Installation initiated?. Please Help...

    C 1 Reply Last reply
    0
    • H honeyashu

      Hi, I needed to find the path of the MSI file through which i am installing the s/w.I needed to check certain file's path during installation(when Installer class is called ... How can i get the path of the msi file from where the Installation initiated?. Please Help...

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Get it from where ? Within the MSI ? You can;t write MSIs in C#, can you ? What I tend to do, is write my install path in the registry, so that other apps can find it later if need be, such as patches.

      Christian Graus Driven to the arms of OSX by Vista.

      H 1 Reply Last reply
      0
      • C Christian Graus

        Get it from where ? Within the MSI ? You can;t write MSIs in C#, can you ? What I tend to do, is write my install path in the registry, so that other apps can find it later if need be, such as patches.

        Christian Graus Driven to the arms of OSX by Vista.

        H Offline
        H Offline
        honeyashu
        wrote on last edited by
        #3

        I think U didn't get me.. I just wanted to know a whether flie (like name 'abc')is in the same folder/path from where my installation package executed. I am using custom installation during which at a time i needed to look for this file if exist ignore else create.. I wanted to add this check when i call Install method..

        C 1 Reply Last reply
        0
        • H honeyashu

          I think U didn't get me.. I just wanted to know a whether flie (like name 'abc')is in the same folder/path from where my installation package executed. I am using custom installation during which at a time i needed to look for this file if exist ignore else create.. I wanted to add this check when i call Install method..

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          What install method ? You say you're calling an install method, but you're talking about MSIs in a C# forum. So, are you using C# to write an MSI ? Are you calling some other sort of method, called install, that runs an MSI ? Are you talking about a C# program, or a process within the MSI ?

          Christian Graus Driven to the arms of OSX by Vista.

          H 1 Reply Last reply
          0
          • C Christian Graus

            What install method ? You say you're calling an install method, but you're talking about MSIs in a C# forum. So, are you using C# to write an MSI ? Are you calling some other sort of method, called install, that runs an MSI ? Are you talking about a C# program, or a process within the MSI ?

            Christian Graus Driven to the arms of OSX by Vista.

            H Offline
            H Offline
            honeyashu
            wrote on last edited by
            #5

            This is the code which i am talking about.. the position i mentioned in the code there i need to find the path for that specified file before calling that Configuration form .. i have to create MSI for my project.. using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration.Install; using System.IO; using System.Reflection; namespace Trade.CustomInstallation { [RunInstaller(true)] public partial class CustomInstallation : Installer { public CustomInstallation() { InitializeComponent(); } public override void Install(System.Collections.IDictionary stateSaver) { "Here I need to Check for the File " ConfigurationForm frmConfig = new ConfigurationForm(); frmConfig.ShowDialog(); base.Install(stateSaver); } protected override void OnAfterUninstall(System.Collections.IDictionary savedState) { base.OnAfterUninstall(savedState); //This method is used to delete all the files after uninstallation. string rootPath = string.Empty; string clientPath = string.Empty; DirectoryInfo directoryInfo = Directory.GetParent(Assembly.GetExecutingAssembly().Location); string currentDirectory = directoryInfo.ToString(); char[] separator = { '\\' }; string[] pathArray = currentDirectory.Split(separator); //condition for Single drive like c:\ if (pathArray.Length == 2 && string.IsNullOrEmpty(pathArray[1])) { rootPath = currentDirectory + "Root"; clientPath = currentDirectory + "Client"; } else { rootPath = currentDirectory + @"\Root"; clientPath = currentDirectory + @"\Client"; } string[] subDirectories = Directory.GetDirectories(currentDirectory); for (int subDirectoryCount = 0; subDirectoryCount < subDirectories.Length; subDirectoryCount++) { //Delete Root Folder if (rootPath.Equals(subDirectories[subDirectoryCount])) Directory.Delete(rootPath, true); //Delete Client Folder if (clientPath.Equals(subDirectories[subDirectoryCount])) Directory.Delete(clientPath, true);

            C 1 Reply Last reply
            0
            • H honeyashu

              This is the code which i am talking about.. the position i mentioned in the code there i need to find the path for that specified file before calling that Configuration form .. i have to create MSI for my project.. using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration.Install; using System.IO; using System.Reflection; namespace Trade.CustomInstallation { [RunInstaller(true)] public partial class CustomInstallation : Installer { public CustomInstallation() { InitializeComponent(); } public override void Install(System.Collections.IDictionary stateSaver) { "Here I need to Check for the File " ConfigurationForm frmConfig = new ConfigurationForm(); frmConfig.ShowDialog(); base.Install(stateSaver); } protected override void OnAfterUninstall(System.Collections.IDictionary savedState) { base.OnAfterUninstall(savedState); //This method is used to delete all the files after uninstallation. string rootPath = string.Empty; string clientPath = string.Empty; DirectoryInfo directoryInfo = Directory.GetParent(Assembly.GetExecutingAssembly().Location); string currentDirectory = directoryInfo.ToString(); char[] separator = { '\\' }; string[] pathArray = currentDirectory.Split(separator); //condition for Single drive like c:\ if (pathArray.Length == 2 && string.IsNullOrEmpty(pathArray[1])) { rootPath = currentDirectory + "Root"; clientPath = currentDirectory + "Client"; } else { rootPath = currentDirectory + @"\Root"; clientPath = currentDirectory + @"\Client"; } string[] subDirectories = Directory.GetDirectories(currentDirectory); for (int subDirectoryCount = 0; subDirectoryCount < subDirectories.Length; subDirectoryCount++) { //Delete Root Folder if (rootPath.Equals(subDirectories[subDirectoryCount])) Directory.Delete(rootPath, true); //Delete Client Folder if (clientPath.Equals(subDirectories[subDirectoryCount])) Directory.Delete(clientPath, true);

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              I didn't know you could write an msi in C#. So, all you need is System.IO.File.Exists to see if a file exists already ?

              Christian Graus Driven to the arms of OSX by Vista.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups