如何解压缩INF文件 [英] How to decompress the INF file

查看:146
本文介绍了如何解压缩INF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我有一个压缩的INF文件。

我必须解压缩INF文件并从中读取数据。



Ex:xxx.in_(包含一些部分和键压缩格式)

i需要将文件解压缩到xxx.inf并需要读取其中的部分。





我使用下面的代码解压缩INF文件。



 使用(FileStream sourceFileStream = File.OpenRead(infFile))
{
using (FileStream destFileStream = File.Create(orgInfFileName))
{
使用(GZipStream decompressingStream = new GZipStream(sourceFileStream,CompressionMode.Decompress) )
{
int byteRead;
while ((byteRead = decompressingStream.ReadByte())!= -1)
{
destFileStream.WriteByte((字节)byteRead);
}
}
}
}





使用这个,我得到一个错误,'GZip标头中的幻数不正确。确保你传递的是GZip流。'



任何人都可以帮忙做这件事。



提前谢谢。

解决方案





也许你的* .in_文件可以通过提取工具expand.exe

可以在你的Windows安装上找到。



如果你能扩展你的* .in_文件使用这个工具



例如expand.exe Template.in_ Template.inf



然后一个解决办法就是从你的C#程序中调用这个工具

,如下所述。



process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden

会抑制任何输出,因此您不会看到弹出的任何命令提示符。



处理流程=  new  Process(); 
process.StartInfo.FileName = expand.exe;
process.StartInfo.Arguments = Template.in_ Template.inf;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();





确保使用系统

.Diagnostics;

项目。



祝你好运,

Stephan


Dear All,

I have an INF file with compressed.
I have to uncompress the INF file and read the data from that.

Ex: xxx.in_ (contains some sections and keys with compressed format)
i need to decompress the file to xxx.inf and needs to read the sections from that.


I used the below code to decompress the INF file.

using (FileStream sourceFileStream = File.OpenRead(infFile))
                        {
                            using (FileStream destFileStream = File.Create(orgInfFileName))
                            {
                                using (GZipStream decompressingStream = new GZipStream(sourceFileStream, CompressionMode.Decompress))
                                {
                                    int byteRead;
                                    while ((byteRead = decompressingStream.ReadByte()) != -1)
                                    {
                                        destFileStream.WriteByte((byte)byteRead);
                                    }
                                }
                            }
                        }



Using this, i am getting an error like, 'The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.'

Could anyone please help to do this.

Thanks in advance.

解决方案

Hi,

maybe your *.in_ file can be extracted by the tool expand.exe
which can be found on your windows installation.

If you are able to expand your *.in_ file by using this tool

e.g. expand.exe Template.in_ Template.inf

then a solution could be to call this tool from your C# programme
as described below.

"process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden"
suppresses any output, so you do not see any command prompt pop up.

Process process = new Process();
process.StartInfo.FileName = "expand.exe";
process.StartInfo.Arguments = "Template.in_ Template.inf";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();



Make sure to have
using System.Diagnostics;
in your project.

Best regards,
Stephan


这篇关于如何解压缩INF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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