如何使用grid将多个文件压缩为单个文件,然后提取到excel并保存在特定文件夹中 [英] how to zip multiple files into single file using grid , and extract into excel and save in a particular folder

查看:113
本文介绍了如何使用grid将多个文件压缩为单个文件,然后提取到excel并保存在特定文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,民谣

如何使用grid将多个文件压缩为单个文件,然后提取到excel并保存在特定文件夹中


我的情况是这样...从网格下载zip文件并解压缩到excel并将这些文件保存在文件夹中.....


如果您有任何代码,请帮助我....





问候
mahesh.b

Hi folk''s

how to zip multiple files into single file using grid , and extract into excel and save in a particular folder


My scenario is in this way ...download zip files from grid and extract into excel and save those files in a folder........


if you have any code please help me....





regard''s
mahesh.b

推荐答案

有人不太可能拥有此代码,因为这对您的设计而言太具体了,并不常见.您的问题是您在精神上试图将所有东西放在一起.您需要一次可以考虑一件事情,并且可以分开关注.

首先,一个网格.不,我不认为它确实包含文件,因此从网格下载"似乎没有任何意义.最有可能的是,它包含一些带有某些URL的数据.因此,首先,您需要知道如何提取URL集合以及一些相关信息(例如目标文件名或URL与其他数据之间的其他映射).为此,您需要从网格读取数据.只需阅读有关此控件的MSDN文档,然后查看您自己的代码即可,在其中用数据填充网格.

下一步是下载.您没有告诉我们它是什么,但是在大多数情况下,这意味着根据文件URL使用FTP或HTTP下载文件.为此,您需要使用一个或多个从 System.Net.WebRequest派生的类:
http://msdn.microsoft.com/en-us/library/system.net. webrequest.aspx [ ^ ].

在上面引用的MSDN页面上,您可以看到所有实现不同协议的非抽象类,请阅读有关该类的帮助(提供代码示例),以及如何进行下载.

剩下的步骤是使用ZIP文件.在这里,您可能需要使用一些第三方库.我建议您考虑考虑#ziplib:
http://www.icsharpcode.net/opensource/sharpziplib/ [ http://en.wikipedia.org/wiki/7-Zip [ http://sevenzipsharp.codeplex.com/ [ ^ ].

这两个ZIP库都是开源的.

现在,您拥有了所需的所有组件.如您所见,大多数工作已经为您完成.您所需要做的就是根据所需的方案将它们放在一起,并使用可用的组件编写代码.你可以自己做.

祝你好运,
—SA
It''s very unlikely that someone has this code, because this is too specific to your design and not very usual. Your problem is that you are mentally trying to put all things together. You need to be able to consider one thing at a time and separate concerns.

First, a grid. No, I don''t believe it really contains files, so "download from grid" does not seem making any sense. Most likely, it contains some data with some URLs. So, first, you need to know how to extract the set of URLs and perhaps some related information (such as target file names or some other mapping between URLs and some other data). For this purpose, you need to read data from a grid. Just read MSDN documentation on this control and look at your own code where you populated the grid with data.

Next step is downloading. You did not inform us on what it is, but in most cases, it means downloading files using FTP or HTTP based on file URLs. To do this, you need to use one or more of classes derived from System.Net.WebRequest:
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^].

On the MSDN page referenced above, you can see all non abstract classes implementing different protocols, read help on that (code samples are available) and see how to do downloads.

The remaining step is working with ZIP files. Here you might need to use some 3-rd party library. I would recommend do consider #ziplib:
http://www.icsharpcode.net/opensource/sharpziplib/[^].

Another option is using SevenZipSharp, a .NET wrapper of the famous 7-Zip:
http://en.wikipedia.org/wiki/7-Zip[^],
http://sevenzipsharp.codeplex.com/[^].

Both ZIP libraries are open-source.

Now you have all the components you need. As you can see, most work is already done for you. All you need is to put it all together according to your required scenario and write the code using available components. You can do you it by yourself.

Good luck,
—SA


这篇关于如何使用grid将多个文件压缩为单个文件,然后提取到excel并保存在特定文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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