List的使用
List<string> AllFilesPath = new List<string>();
if (filesOrDirectoriesPaths.Length > ) // get all files path
{
for (int i = ; i < filesOrDirectoriesPaths.Length; i++)
{
if (File.Exists(@strZipTopDirectoryPath + filesOrDirectoriesPaths[i]))
{
AllFilesPath.Add(strZipTopDirectoryPath + filesOrDirectoriesPaths[i]);
}
else if (Directory.Exists(@strZipTopDirectoryPath + filesOrDirectoriesPaths[i]))
{
GetDirectoryFiles(filesOrDirectoriesPaths[i], AllFilesPath);
}
}
}
for (int i = 0; i < AllFilesPath.Count; i++)
{
string strFile = AllFilesPath[i].ToString();
try
{
if (strFile.Substring(strFile.Length - 1) == "") //folder
{
string strFileName = strFile.Replace(strZipTopDirectoryPath, "");
if (strFileName.StartsWith(""))
{
strFileName = strFileName.Substring(1);
}
ZipEntry entry = new ZipEntry(strFileName);
entry.DateTime = DateTime.Now;
zipOutputStream.PutNextEntry(entry);
}
else //file
{
FileStream fs = File.OpenRead(strFile); byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length); string strFileName = strFile.Replace(strZipTopDirectoryPath, "");
if (strFileName.StartsWith(""))
{
strFileName = strFileName.Substring(0);
}
ZipEntry entry = new ZipEntry(strFileName);
entry.DateTime = DateTime.Now;
zipOutputStream.PutNextEntry(entry);
zipOutputStream.Write(buffer, 0, buffer.Length); fs.Close();
fs.Dispose();
}
}
catch
{
continue;
}
}
随机推荐
- java 进程启用远程查看
用jconsole 1.启动脚本增加: JAVA_OPTS="-Djava.net.preferIPv4Stack=true -Djava.rmi.server.hostname=192.1 ...
- Farey Sequence
Description The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rationa ...
- COM调用 – VB、PB
本文使用Delphi和C++创建CRC32的COM文件(Dll). VB: V6.0 PB: V8.0 Delphi创建的文件,提供给VB6调用:C++创建的文件,提供给PB8调用. 一.VB部分 C ...
- jquery 选择器汇总
jQueryAPI_1.7.1_CN.chm下载地址http://download.csdn.net/detail/zhai123_/6459563 jquery 选择器大体上可分为4 类: 1.基本 ...
- 扩展运算是个影藏boss
short a =1; a+=1; //实际上是 a=(short)(a+1); 而 short a=1; a=a+1; //不报错,应为进行算术逻辑运算会默认转为int类型,但是你要把int类型赋值 ...
- java, poi, excel
工作需要用java操作Excel,现在网上搜索了一下,决定选取POI包来操作.pom内容如下: <dependency> <groupId>org.apache.poi< ...
- c#基础-类型基础深入了解
对象类型需要动态内存,基础类型需要静态内存 动态内存分配在堆上,静态内存分配在栈上. 静态内存保存着简单的变量,如 int a=0; 值类型:把一个值类型赋值给另外一个值类型,改变其中一个另外一个不会 ...
- Python在安装第三方模块遇到的问题及解决办法
今天在安装第一个模块psutil的时候出现了以下问题: 1.找不到Python.h文件 解决办法:重新安装python环境:sudo apt-get install python-dev 说明:网上有 ...
- 【转】awk、nawk、mawk、gawk的简答介绍
来自http://blog.sina.com.cn/s/blog_3d2d79aa0100h47h.html awk 是一种编程语言,用于在linux/unix下对文本和数据进行处理.数据可以来自标准 ...
- loadrunner工具使用之脚本创建
loadrunner工具使用之脚本创建 一.创建脚本 1.打开loadrunner,选择第一个控件VuGen(创建/编辑脚本),点击