使用.NET 2.0解压缩文件 [英] Unzip file using .NET 2.0

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

问题描述

我想将一些压缩的XML文件传递到与.NET 2.0兼容的SQL Server 2008中.(实现将c#导入为CLR).

I want to pass some zipped XML files into SQL Server 2008 which is compatible with .NET 2.0. (implementing c# to be imported as CLR).

我从API下载了一个.zip文件,该.zip文件包含多个XML文件.有什么方法可以使用.NET 2.0来解压缩XML的 吗?无法使用外部库.

I downloaded a .zip file from an API and this .zip file contains several XML files. Is there any way to decompress the get the XML's using .NET 2.0? The use of external libraries is not possible.

文件的导出是通过以下代码完成的:

The export of the file is done by this code:

byte[] varbinary = GetStreamFileResult(..);
string tempPath = Path.GetTempPath()+ "temp.zip";
File.WriteAllBytes(tempPath, varbinary); // Requires System.IO

在我的研究中,我找到了 this 这样的解决方案,但是它们是不适用于我的情况.

In my research I found solution like this but they are not applicable to my case.

推荐答案

在框架的更高版本中:这很容易获得.

In later versions of the framework: this is readily available.

在2.0版中:有外部库对此进行了公开,但是您说那是不允许的.

In 2.0: there are external libraries that expose this, but you say that isn't allowed.

因此:如果它不在2.0框架中,并且您不能使用外部库,则必须从头开始编写zip解码器.这是大量的工作,几乎可以肯定不是一个好主意.挑战两个施加的限制中的任何一个都是更好的举动.或者:停止尝试在数据库内部运行应用程序代码(这不是它的初衷).

So: if it isn't in the 2.0 framework and you can't use external libraries, you'd have to code a zip decoder from scratch. This is a significant amount of work and is almost certainly not a good idea. It would be a better move to challenge either of the two imposed limitations. Or: stop trying to run application code inside the database (that isn't what it is intended for).

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

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