如何解决在C#MSI的路径? [英] How can I resolve MSI paths in C#?

查看:181
本文介绍了如何解决在C#MSI的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从MSI数据库解决目标路径,安装之外。我目前做这通过查询数据库的目录和文件表,并从那里构建路径使用维克斯SDK,但解决路径似乎喜欢的事,应该已经内置。 ?有没有这样做,甚至一些非官方的,还是我坚持做我自己的库

I need to resolve target paths from an MSI database, outside of the installation. I am currently doing this using the Wix SDK by querying the database's Directory and File tables and constructing the paths from there, but resolving paths seems like something that should already be built-in. Is there a library that does this, even something unofficial, or am I stuck with doing it on my own?

这问题有的already~~V被要求对于C ++,但唯一的答案某种程度上误解了这个问题是关于字符串。

This question has already been asked for C++, but the only answer somehow misunderstood the question to be about strings.

我不介意的性能。我真正关心的是解决之类的特殊文件夹:,:,字体的Windows:WINROOT等等 - 我仍然可以做我自己的代码,但不是很优雅。

I don't really mind performance. My real concern is with resolving special folders like ".:Fonts", ".:Windows", ".:WinRoot", etc. - which I can still do in my own code but not very elegantly.

推荐答案

我没有你这样做的时候DTF第一次来到了同样的事情。我写的所有查询和循环让我在工作中的数据。而且性能是那种痛苦的。

I did the same thing you did when DTF first came out. I wrote all the queries and loops to get the data I was working for. And the performance was kind of painful.

然后我注意到在Microsoft.Deployment.WindowsInstaller.Package装配InstallPackage类。当我看到下面的代码是如何快速和简单的使用这个类,我觉得那种愚蠢的:

Then I noticed the InstallPackage class in the Microsoft.Deployment.WindowsInstaller.Package assembly. I felt kind of silly when I saw how fast and simple the following code is using that class:

using System;
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.Deployment.WindowsInstaller.Package;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var package = new InstallPackage("foo.msi", DatabaseOpenMode.ReadOnly))
            {
                foreach (var filePath in package.Files)
                {
                    Console.WriteLine(filePath.Value);
                }
                Console.WriteLine("Finished");
                Console.Read();
            }
        }
    }
}

这篇关于如何解决在C#MSI的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆