如何从存储在二进制表中的文件中检索文本?

问题描述 投票:0回答:1

我想检索存储在 MSI 二进制表中的脚本。 我怎样才能做到这一点?

我试过这个:

string query = $"SELECT `Data` FROM `Binary` WHERE `Name`='{sourceName_}'";

using (View view = db_.OpenView(query))
{
    view.Execute();
    Record record = view.Fetch();
    Stream data = record.GetStream(1);    // "data" should contain the script.
    // I don't know what to do with "data" or
    // if it's the right way to do it.
}
c# sql windows-installer
1个回答
0
投票

Record 应该为您提供一个“get_StringData”方法,您应该能够从中读取。

string query = $"SELECT `Data` FROM `Binary` WHERE `Name`='{sourceName_}'";

using (View view = db_.OpenView(query))
{
    // Execute the view query
    view.Execute(null);

    // Get the record from the view
    Record record = view.Fetch();

    while (record != null)
    {
        Console.WriteLine(record.get_StringData(0) + '=' + record.get_StringData(1) + '=' + record.get_StringData(2) + '=' +record.get_StringData(3));
        record = view.Fetch();
    }
}

我从this问题得到这个。 他们还提到,使用 Microsoft.Deployment.WindowsInstaller MSI 互操作库中的“XML 部署工具基础 (WiX DTF)”可能会更容易

© www.soinside.com 2019 - 2024. All rights reserved.