/// <summary> /// Gets the full path to the designated folder on the installation target drive. /// </summary> /// <exception cref="ArgumentException">the folder was not found in the Directory table</exception> /// <exception cref="InvalidHandleException">the Session handle is invalid</exception> /// <remarks><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msigettargetpath.asp">MsiGetTargetPath</a> /// </p></remarks> public string GetTargetPath(string directory) { if (string.IsNullOrWhiteSpace(directory)) { throw new ArgumentNullException("directory"); } this.ValidateSessionAccess(); StringBuilder buf = new StringBuilder(); uint bufSize = 0; uint ret = RemotableNativeMethods.MsiGetTargetPath((int)this.Handle, directory, buf, ref bufSize); if (ret == (uint)NativeMethods.Error.MORE_DATA) { buf.Capacity = (int)++bufSize; ret = ret = RemotableNativeMethods.MsiGetTargetPath((int)this.Handle, directory, buf, ref bufSize); } if (ret != 0) { if (ret == (uint)NativeMethods.Error.DIRECTORY) { throw InstallerException.ExceptionFromReturnCode(ret, directory); } else { throw InstallerException.ExceptionFromReturnCode(ret); } } return(buf.ToString()); }