<?xml version="1.0" standalone="yes"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>清风的blog - 技术文章</title><link>http://blog.careff.com/</link><description>优然探索 - </description><generator>RainbowSoft Studio Z-Blog 2.2 Prism Build 140101</generator><language>zh-CN</language><copyright>Copyright (C) 2008-2024 careff.com Inc.,All  Rights Reserved.                    雅虎统计      </copyright><pubDate>Tue, 09 Jun 2026 11:30:25 +0800</pubDate><item><title>自动安装.NET2.0</title><author>a@b.com (admin)</author><link>http://blog.careff.com/post/388.html</link><pubDate>Mon, 14 Apr 2014 15:25:41 +0800</pubDate><guid>http://blog.careff.com/post/388.html</guid><description><![CDATA[<p>if not exist &quot;%WINDIR%\Microsoft.NET\Framework\v2.*&quot; (<br />echo 需要您自己安装 Net 2.0,系统自动打开安装地址<br />start <a href="http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&amp;displaylang=zh-cn">http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&amp;displaylang=zh-cn</a><br />pause</p><p>) else (<br />start bin/Cassini.exe</p><p>)<br />exit</p>]]></description><category>技术文章</category><comments>http://blog.careff.com/post/388.html#comment</comments><wfw:commentRss>http://blog.careff.com/feed.asp?cmt=388</wfw:commentRss></item><item><title>SQL SERVER 数据库备份与还原 命令  </title><author>a@b.com (admin)</author><link>http://blog.careff.com/post/387.html</link><pubDate>Fri, 21 Feb 2014 08:11:19 +0800</pubDate><guid>http://blog.careff.com/post/387.html</guid><description><![CDATA[<p>&nbsp;<span style="color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">SQL Server 2000 数据库备份与还原在查询分析器中,使用 SQL 命令备份系统数据库或用户数据库,然后又使用 SQL 命令 还原数据库</span><a name="baidusnap1" rel="nofollow" style="font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px; color: rgb(221, 53, 53);"></a><span style="color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">.</span><span style="color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">&nbsp;</span><strong style="color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">一,备份数据库</strong></p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">例如:&nbsp;<font color="#ff0000">BACKUP DATABASE Northwind TO DISK = 'c:\Northwind.bak'</font></p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><strong>二,还原数据库</strong></p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">例如: --返回由备份集内包含的数据库和日志文件列表组成的结果集</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">返回由备份集内包含的数据库和日志文件列表组成的结果集</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><font color="#ff0000">RESTORE FILELISTONLY FROM DISK = 'c:\Northwind.bak'</font></p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">--还原由 BACKUP 备份的数据库</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">还原由&nbsp;<font color="#ff0000">RESTORE DATABASE Northwind FROM DISK = 'c:\Northwind.bak'</font></p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">--指定还原后的数据库物理文件名称及路径,这里得在 SQL Server 数据库管理系统中,</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">先 指定还原后的数据库物理文件名称及路径, 数据库管理系统中, 指定还原后的数据库物理文件名称及路径</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">创建数据库名为 Test 的数据库, 的数据库, 并且指定 mdf 文件和 ldf 文件在 C 盘 test 文件夹下. 文件夹下.否则,</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">否则, 在还原的时候,找不到指定的路径. 在还原的时候,找不到指定的路径.</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">RESTORE DATABASE Test FROM DISK = 'c:\Northwind.bak' WITH MOVE 'Northwind' TO 'c:\test\testdb.mdf', MOVE 'Northwind_log' TO 'c:\test\testdb.ldf' MOVE 'logical_file_name' TO 'operating_system_file_name'</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">指 定 应 将 给 定 的 logical_file_name 移 到 operating_system_file_name .</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">&nbsp;默 认 情 况 下 , logical_file_name 将还原到其原始位置.如果使用 RESTORE 语句将数据库复制到相同或 不同的服务器上,则可能需要使用 MOVE 选项重新定位数据库文件以避免与现有文件冲 突.可以在不同的 MOVE 语句中指定数据库内的每个逻辑文件.</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">--强制还原,加上 REPLACE 参数,则在现有数据库基础上强制还原. 强制还原, 参数,则在现有数据库基础上强制还原.</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">强制还原</p><p style="line-height: 28px; margin: 0px 0px 10px; padding: 0px; color: rgb(68, 68, 68); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><font color="#ff0000">RESTORE DATABASE Test FROM DISK = 'c:\Northwind.bak' WITH REPLACE, MOVE 'Northwind' TO 'c:\test\testdb.mdf', MOVE 'Northwind_log' TO 'c:\test\testdb.ldf'</font></p>]]></description><category>技术文章</category><comments>http://blog.careff.com/post/387.html#comment</comments><wfw:commentRss>http://blog.careff.com/feed.asp?cmt=387</wfw:commentRss></item><item><title>http://tonyqus.sinaapp.com/</title><author>a@b.com (admin)</author><link>http://blog.careff.com/post/383.html</link><pubDate>Fri, 14 Feb 2014 11:12:01 +0800</pubDate><guid>http://blog.careff.com/post/383.html</guid><description><![CDATA[<p>&nbsp;http://tonyqus.sinaapp.com/</p>]]></description><category>技术文章</category><comments>http://blog.careff.com/post/383.html#comment</comments><wfw:commentRss>http://blog.careff.com/feed.asp?cmt=383</wfw:commentRss></item><item><title>Npoi操作excel</title><author>a@b.com (admin)</author><link>http://blog.careff.com/post/382.html</link><pubDate>Fri, 14 Feb 2014 10:12:16 +0800</pubDate><guid>http://blog.careff.com/post/382.html</guid><description><![CDATA[<p>&nbsp;</p><h1 class="postTitle" style="margin: 0px 0px 15px; padding: 0px 0px 0px 5px; font-size: 16px; float: left; line-height: 1.5em; width: 1293.75px; clear: both; color: rgb(70, 70, 70); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; background-color: rgb(250, 247, 239);"><a id="cb_post_title_url" class="postTitle2" href="http://www.cnblogs.com/knowledgesea/archive/2012/11/16/2772547.html" style="margin: 0px; padding: 3px; color: rgb(100, 102, 179); text-decoration: none; font-family: 微软雅黑, Consolas, Arial, 宋体;">Npoi操作excel</a></h1><div class="clear" style="margin: 0px; padding: 0px; clear: both; color: rgb(70, 70, 70); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: normal; background-color: rgb(250, 247, 239);">&nbsp;</div><div class="postBody" style="margin: 0px; padding: 5px 2px 5px 5px; line-height: 1.5; color: rgb(57, 57, 57); border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: black; font-size: 14px; font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; background-color: rgb(250, 247, 239);"><div id="cnblogs_post_body" style="margin: 0px 0px 20px; padding: 0px; font-family: 'Courier New', 微软雅黑, Consolas, Arial, 宋体; font-size: 13px;"><p style="margin: 10px auto; padding: 5px 0px;"><span style="margin: 0px; padding: 0px; font-size: 18px;"><strong style="margin: 0px; padding: 0px;">Npoi&nbsp;简介</strong></span></p><hr style="margin: 0px; padding: 0px;" /><p style="margin: 10px auto; padding: 5px 0px;"><span style="margin: 0px; padding: 0px; font-size: 18px;">1<span style="margin: 0px; padding: 0px; font-size: 14px;">.整个Excel表格叫做工作表：WorkBook（工作薄），包含的叫页（工作表）：Sheet；行：Row；单元格Cell。</span></span></p><p style="margin: 10px auto; padding: 5px 0px;"><span style="margin: 0px; padding: 0px; font-size: 18px;"><span style="margin: 0px; padding: 0px; font-size: 14px;">2.Npoi&nbsp;下载地址：<a href="http://npoi.codeplex.com/releases/view/38113" style="margin: 0px; padding: 1px 2px; color: rgb(91, 157, 202); text-decoration: none;">http://npoi.codeplex.com/releases/view/38113</a></span></span></p><p style="margin: 10px auto; padding: 5px 0px;"><span style="margin: 0px; padding: 0px; font-size: 18px;"><span style="margin: 0px; padding: 0px; font-size: 14px;">3.Npoi&nbsp;学习系列教程推荐：<a href="http://www.cnblogs.com/tonyqus/archive/2009/04/12/1434209.html" style="margin: 0px; padding: 1px 2px; color: rgb(91, 157, 202); text-decoration: none;">http://www.cnblogs.com/tonyqus/archive/2009/04/12/1434209.html</a><br style="margin: 0px; padding: 0px;" /></span></span></p><p style="margin: 10px auto; padding: 5px 0px;"><span style="margin: 0px; padding: 0px; font-size: 18px;"><span style="margin: 0px; padding: 0px; font-size: 14px;">4.忘了告诉大家npoi是做什么的了，npoi 能够读写几乎所有的Office 97-2003文件格式，至少能够支持Word, PowerPoint, Excel, Visio的格式。</span></span></p><hr style="margin: 0px; padding: 0px;" /><p style="margin: 10px auto; padding: 5px 0px;"><span style="margin: 0px; padding: 0px; font-size: 18px;"><span style="margin: 0px; padding: 0px; font-size: 14px;"><span style="margin: 0px; padding: 0px; font-size: 18px;"><strong style="margin: 0px; padding: 0px;">使用Npoi创建一个简单的xls文件</strong></span></span></span></p><hr style="margin: 0px; padding: 0px;" /><p style="margin: 10px auto; padding: 5px 0px;">&nbsp;</p><div class="cnblogs_code" style="margin: 5px 0px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; font-family: 'Courier New' !important; font-size: 12px !important;"><div class="cnblogs_code_toolbar" style="margin: 5px 0px 0px; padding: 0px;"><span class="cnblogs_code_copy" style="margin: 0px; padding: 0px 5px 0px 0px; line-height: 1.5 !important;"><a title="复制代码" style="margin: 0px; padding: 1px 2px; color: rgb(91, 157, 202); border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="margin: 0px; padding: 0px; border: none !important;" /></a></span></div><pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: 'Courier New', Consolas; font-size: 10pt;">  <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">创建xls文件</span>        <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">private</span> <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">void</span> button1_Click(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">object</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> sender, EventArgs e)         {             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">创建工作薄</span>            HSSFWorkbook wk = <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">new</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> HSSFWorkbook();             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">创建一个名称为mySheet的表</span>            ISheet tb = wk.CreateSheet(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">mySheet</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);              </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">创建一行，此行为第二行</span>            IRow row = tb.CreateRow(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">1</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">for</span> (<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">int</span> i = <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span>; i &lt; <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">20</span>; i++<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">)                 {                 ICell cell </span>= row.CreateCell(i);  <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">在第二行中创建单元格</span>                cell.SetCellValue(i);<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">循环往第二行的单元格中添加数据</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">            }             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">using</span> (FileStream fs = File.OpenWrite(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">@&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">c:/myxls.xls</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span>)) <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">打开一个xls文件，如果没有则自行创建，如果存在myxls.xls文件则在创建是不要打开该文件！</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">            {                 wk.Write(fs);   </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">向打开的这个xls文件中写入mySheet表并保存。</span>                MessageBox.Show(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">提示：创建成功！</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             }         }</span></pre><div class="cnblogs_code_toolbar" style="margin: 5px 0px 0px; padding: 0px;"><span class="cnblogs_code_copy" style="margin: 0px; padding: 0px 5px 0px 0px; line-height: 1.5 !important;"><a title="复制代码" style="margin: 0px; padding: 1px 2px; color: rgb(91, 157, 202); border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="margin: 0px; padding: 0px; border: none !important;" /></a></span></div></div><hr style="margin: 0px; padding: 0px;" /><p style="margin: 10px auto; padding: 5px 0px;"><span style="margin: 0px; padding: 0px; font-size: 18px;"><span style="margin: 0px; padding: 0px; font-size: 14px;"><span style="margin: 0px; padding: 0px; font-size: 18px;"><strong style="margin: 0px; padding: 0px;">使用Npoi读取一个简单的xls文件</strong></span></span></span></p><hr style="margin: 0px; padding: 0px;" /><div class="cnblogs_code" style="margin: 5px 0px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; font-family: 'Courier New' !important; font-size: 12px !important;"><div class="cnblogs_code_toolbar" style="margin: 5px 0px 0px; padding: 0px;"><span class="cnblogs_code_copy" style="margin: 0px; padding: 0px 5px 0px 0px; line-height: 1.5 !important;"><a title="复制代码" style="margin: 0px; padding: 1px 2px; color: rgb(91, 157, 202); border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="margin: 0px; padding: 0px; border: none !important;" /></a></span></div><pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: 'Courier New', Consolas; font-size: 10pt;"> <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">读取xls文件</span>        <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">private</span> <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">void</span> button2_Click(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">object</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> sender, EventArgs e)         {   StringBuilder sbr </span>= <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">new</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> StringBuilder();             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">using</span> (FileStream fs = File.OpenRead(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">@&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">c:/myxls.xls</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span>))   <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">打开myxls.xls文件</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">            {                 HSSFWorkbook wk </span>= <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">new</span> HSSFWorkbook(fs);   <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">把xls文件中的数据写入wk中</span>                <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">for</span> (<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">int</span> i = <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span>; i &lt; wk.NumberOfSheets; i++)  <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">NumberOfSheets是myxls.xls中总共的表数</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">                {                     ISheet sheet </span>= wk.GetSheetAt(i);   <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">读取当前表数据</span>                    <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">for</span> (<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">int</span> j = <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span>; j &lt;= sheet.LastRowNum; j++)  <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">LastRowNum 是当前表的总行数</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">                    {                         IRow row </span>= sheet.GetRow(j);  <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">读取当前行数据</span>                        <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">if</span> (row != <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">null</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">)                         {                             sbr.Append(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">-------------------------------------\r\n</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span>); <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">读取行与行之间的提示界限</span>                            <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">for</span> (<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">int</span> k = <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span>; k &lt;= row.LastCellNum; k++)  <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">LastCellNum 是当前行的总列数</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">                            {                                 ICell cell </span>= row.GetCell(k);  <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">当前表格</span>                                <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">if</span> (cell != <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">null</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">)                                 {                                                                        sbr.Append(cell.ToString());   </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">获取表格中的数据并转换为字符串类型</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">                                }                             }                         }                     }                 }                            }             sbr.ToString();             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">using</span> (StreamWriter wr = <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">new</span> StreamWriter(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">new</span> FileStream(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">@&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">c:/myText.txt</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span>, FileMode.Append)))  <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">把读取xls文件的数据写入myText.txt文件中</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">            {                 wr.Write(sbr.ToString());                 wr.Flush();             }                      }</span></pre><div class="cnblogs_code_toolbar" style="margin: 5px 0px 0px; padding: 0px;"><span class="cnblogs_code_copy" style="margin: 0px; padding: 0px 5px 0px 0px; line-height: 1.5 !important;"><a title="复制代码" style="margin: 0px; padding: 1px 2px; color: rgb(91, 157, 202); border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="margin: 0px; padding: 0px; border: none !important;" /></a></span></div></div><hr style="margin: 0px; padding: 0px;" /><p style="margin: 10px auto; padding: 5px 0px;"><span style="margin: 0px; padding: 0px; font-size: 18px;"><span style="margin: 0px; padding: 0px; font-size: 14px;"><span style="margin: 0px; padding: 0px; font-size: 18px;"><strong style="margin: 0px; padding: 0px;">使用Npoi创建一个常用的xls文件</strong></span></span></span></p><hr style="margin: 0px; padding: 0px;" /><p style="margin: 10px auto; padding: 5px 0px;">&nbsp;</p><div class="cnblogs_code" style="margin: 5px 0px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; font-family: 'Courier New' !important; font-size: 12px !important;"><div class="cnblogs_code_toolbar" style="margin: 5px 0px 0px; padding: 0px;"><span class="cnblogs_code_copy" style="margin: 0px; padding: 0px 5px 0px 0px; line-height: 1.5 !important;"><a title="复制代码" style="margin: 0px; padding: 1px 2px; color: rgb(91, 157, 202); border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="margin: 0px; padding: 0px; border: none !important;" /></a></span></div><pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: 'Courier New', Consolas; font-size: 10pt;"> <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">创建一个常用的xls文件</span>        <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">private</span> <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">void</span> button3_Click(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">object</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> sender, EventArgs e)         {                       IWorkbook wb </span>= <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">new</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> HSSFWorkbook();             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">创建表  </span>            ISheet sh = wb.CreateSheet(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">zhiyuan</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">设置单元的宽度  </span>            sh.SetColumnWidth(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span>, <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">15</span> * <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">256</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             sh.SetColumnWidth(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">1</span>, <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">35</span> * <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">256</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             sh.SetColumnWidth(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">2</span>, <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">15</span> * <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">256</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             sh.SetColumnWidth(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">3</span>, <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">10</span> * <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">256</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">int</span> i = <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">#region</span> 练习合并单元格<br style="margin: 0px; padding: 0px;" /><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">            sh.AddMergedRegion(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">new</span> NPOI.SS.Util.CellRangeAddress(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span>, <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span>, <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span>, <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">3</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">));<br style="margin: 0px; padding: 0px;" /> &nbsp;           //CellRangeAddress（）该方法的参数次序是：开始行号，结束行号，开始列号，结束列号。<br style="margin: 0px; padding: 0px;" />  <br style="margin: 0px; padding: 0px;" />            IRow row0 </span>= sh.CreateRow(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             row0.Height </span>= <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">20</span> * <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">20</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;             ICell icell1top0 </span>= row0.CreateCell(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             icell1top0.CellStyle </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> Getcellstyle(wb, stylexls.头);             icell1top0.SetCellValue(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">标题合并单元</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">#endregion</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">             i</span>++<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">#region</span> 设置表头<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">             IRow row1 </span>= sh.CreateRow(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">1</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             row1.Height </span>= <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">20</span> * <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">20</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;              ICell icell1top </span>= row1.CreateCell(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             icell1top.CellStyle </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> Getcellstyle(wb, stylexls.头);             icell1top.SetCellValue(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">网站名</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);              ICell icell2top </span>= row1.CreateCell(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">1</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             icell2top.CellStyle </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> Getcellstyle(wb, stylexls.头);             icell2top.SetCellValue(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">网址</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);              ICell icell3top </span>= row1.CreateCell(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">2</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             icell3top.CellStyle </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> Getcellstyle(wb, stylexls.头);             icell3top.SetCellValue(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">百度快照</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);              ICell icell4top </span>= row1.CreateCell(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">3</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             icell4top.CellStyle </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> Getcellstyle(wb, stylexls.头);             icell4top.SetCellValue(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">百度收录</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">#endregion</span>                <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">using</span>(FileStream stm=File.OpenWrite(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">@&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">c:/myMergeCell.xls</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">))             {                 wb.Write(stm);                  MessageBox.Show(</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">提示：创建成功！</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);             }         }            </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">#region</span> 定义单元格常用到样式的枚举        <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">public</span> <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">enum</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> stylexls         {             头,             url,             时间,             数字,             钱,             百分比,             中文大写,             科学计数法,             默认         }         </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">#endregion</span>        <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">#region</span> 定义单元格常用到样式        <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">static</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> ICellStyle Getcellstyle(IWorkbook wb, stylexls str)         {             ICellStyle cellStyle </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> wb.CreateCellStyle();              </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">定义几种字体               </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">也可以一种字体，写一些公共属性，然后在下面需要时加特殊的  </span>            IFont font12 =<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> wb.CreateFont();             font12.FontHeightInPoints </span>= <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">10</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;             font12.FontName </span>= <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">微软雅黑</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;               IFont font </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> wb.CreateFont();             font.FontName </span>= <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">微软雅黑</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">font.Underline = 1;下划线  </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">              IFont fontcolorblue </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> wb.CreateFont();             fontcolorblue.Color </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> HSSFColor.OLIVE_GREEN.BLUE.index;             fontcolorblue.IsItalic </span>= <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">true</span>;<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">下划线  </span>            fontcolorblue.FontName = <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">微软雅黑</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;               </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">边框  </span>            cellStyle.BorderBottom =<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> NPOI.SS.UserModel.BorderStyle.DOTTED;             cellStyle.BorderLeft </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> NPOI.SS.UserModel.BorderStyle.HAIR;             cellStyle.BorderRight </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> NPOI.SS.UserModel.BorderStyle.HAIR;             cellStyle.BorderTop </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> NPOI.SS.UserModel.BorderStyle.DOTTED;             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">边框颜色  </span>            cellStyle.BottomBorderColor =<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> HSSFColor.OLIVE_GREEN.BLUE.index;             cellStyle.TopBorderColor </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> HSSFColor.OLIVE_GREEN.BLUE.index;              </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">背景图形，我没有用到过。感觉很丑               </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">cellStyle.FillBackgroundColor = HSSFColor.OLIVE_GREEN.BLUE.index;               </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">cellStyle.FillForegroundColor = HSSFColor.OLIVE_GREEN.BLUE.index;  </span>            cellStyle.FillForegroundColor =<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> HSSFColor.WHITE.index;             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);"> cellStyle.FillPattern = FillPatternType.NO_FILL;  </span>            cellStyle.FillBackgroundColor =<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> HSSFColor.BLUE.index;              </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">水平对齐  </span>            cellStyle.Alignment =<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> NPOI.SS.UserModel.HorizontalAlignment.LEFT;              </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">垂直对齐  </span>            cellStyle.VerticalAlignment =<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> VerticalAlignment.CENTER;              </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">自动换行  </span>            cellStyle.WrapText = <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">true</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;              </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">缩进;当设置为1时，前面留的空白太大了。希旺官网改进。或者是我设置的不对  </span>            cellStyle.Indention = <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">0</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;              </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">上面基本都是设共公的设置               </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">下面列出了常用的字段类型  </span>            <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">switch</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> (str)             {                 </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">case</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> stylexls.头:                     </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);">//</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 128, 0);"> cellStyle.FillPattern = FillPatternType.LEAST_DOTS;  </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">                    cellStyle.SetFont(font12);                     </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">break</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;                 </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">case</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> stylexls.时间:                     IDataFormat datastyle </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> wb.CreateDataFormat();                      cellStyle.DataFormat </span>= datastyle.GetFormat(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">yyyy/mm/dd</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);                     cellStyle.SetFont(font);                     </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">break</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;                 </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">case</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> stylexls.数字:                     cellStyle.DataFormat </span>= HSSFDataFormat.GetBuiltinFormat(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">0.00</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);                     cellStyle.SetFont(font);                     </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">break</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;                 </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">case</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> stylexls.钱:                     IDataFormat format </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> wb.CreateDataFormat();                     cellStyle.DataFormat </span>= format.GetFormat(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">￥#,##0</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);                     cellStyle.SetFont(font);                     </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">break</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;                 </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">case</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> stylexls.url:                     fontcolorblue.Underline </span>= <span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 128);">1</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;                     cellStyle.SetFont(fontcolorblue);                     </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">break</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;                 </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">case</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> stylexls.百分比:                     cellStyle.DataFormat </span>= HSSFDataFormat.GetBuiltinFormat(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">0.00%</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);                     cellStyle.SetFont(font);                     </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">break</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;                 </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">case</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> stylexls.中文大写:                     IDataFormat format1 </span>=<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> wb.CreateDataFormat();                     cellStyle.DataFormat </span>= format1.GetFormat(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">[DbNum2][$-804]0</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);                     cellStyle.SetFont(font);                     </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">break</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;                 </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">case</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> stylexls.科学计数法:                     cellStyle.DataFormat </span>= HSSFDataFormat.GetBuiltinFormat(<span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">0.00E+00</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(128, 0, 0);">&quot;</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">);                     cellStyle.SetFont(font);                     </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">break</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;                 </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">case</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> stylexls.默认:                     cellStyle.SetFont(font);                     </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">break</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);">;             }             </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">return</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 0);"> cellStyle;           }         </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New' !important; font-size: 12px !important; line-height: 1.5 !important; color: rgb(0, 0, 255);">#endregion</span>  </pre></div></div></div>]]></description><category>技术文章</category><comments>http://blog.careff.com/post/382.html#comment</comments><wfw:commentRss>http://blog.careff.com/feed.asp?cmt=382</wfw:commentRss></item><item><title>遍历表，打开插入自动ID</title><author>a@b.com (admin)</author><link>http://blog.careff.com/post/378.html</link><pubDate>Mon, 14 Oct 2013 14:03:01 +0800</pubDate><guid>http://blog.careff.com/post/378.html</guid><description><![CDATA[<p>DECLARE @SQL NVARCHAR(4000);<br />DECLARE @ANAME VARCHAR(500);<br />DECLARE LC_CURSOR CURSOR FOR <br />SELECT NAME FROM SYSOBJECTS WHERE TYPE = 'U';<br />OPEN&nbsp; LC_CURSOR<br />&nbsp;&nbsp;--遍历表<br />FETCH NEXT FROM LC_CURSOR INTO @ANAME<br />&nbsp;WHILE(@@FETCH_STATUS=0)<br />&nbsp;BEGIN<br />&nbsp;&nbsp;--PRINT @ANAME<br />&nbsp;&nbsp;PRINT 'SET IDENTITY_INSERT <a href="mailto:'+@ANAME+'">'+@ANAME+'</a> on';<br />&nbsp;&nbsp;--PRINT 'SET IDENTITY_INSERT <a href="mailto:'+@ANAME+'">'+@ANAME+'</a> off';<br />&nbsp;&nbsp;FETCH NEXT FROM LC_CURSOR INTO @ANAME<br />&nbsp;END</p><p>CLOSE LC_CURSOR<br />DEALLOCATE LC_CURSOR</p><p>&nbsp;</p>]]></description><category>技术文章</category><comments>http://blog.careff.com/post/378.html#comment</comments><wfw:commentRss>http://blog.careff.com/feed.asp?cmt=378</wfw:commentRss></item><item><title>C# 导出XML格式EXCEL文件</title><author>a@b.com (admin)</author><link>http://blog.careff.com/post/375.html</link><pubDate>Wed, 31 Jul 2013 13:32:41 +0800</pubDate><guid>http://blog.careff.com/post/375.html</guid><description><![CDATA[<p>&nbsp;using System;</p><div>using System.Collections;</div><div>using System.Configuration;</div><div>using System.Data;</div><div>using System.Web;</div><div>using System.Web.Security;</div><div>using System.Web.UI;</div><div>using System.Web.UI.HtmlControls;</div><div>using System.Web.UI.WebControls;</div><div>using System.Web.UI.WebControls.WebParts;</div><div>using System.IO;</div><div>&nbsp;</div><div>namespace WebApplication1</div><div>{</div><div>&nbsp; &nbsp; public partial class _Default : System.Web.UI.Page</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public string sConn = &quot;Data Source=LC_QZF;Initial Catalog=SchoolDB;User ID=sa;Password=00000000&quot;;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; protected void Page_Load(object sender, EventArgs e)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!Page.IsPostBack)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string path = DataSetToExcel_XML(&quot;select top 10 * from SkyDictionary&quot;, sConn);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.Write(path);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;summary&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// 使用XML方式导出Excel</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;/summary&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;param name=&quot;SQL&quot;&gt;&lt;/param&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;param name=&quot;AdoConn&quot;&gt;数据库连接字符&lt;/param&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;returns&gt;EXCEL文件所在的地址&lt;/returns&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; private String DataSetToExcel_XML(String SQL, String AdoConn)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string ExcelFileName = Server.MapPath(&quot;a&quot;+DateTime.Now.ToString(&quot;yyyyMMdd-HHmmss&quot;)+&quot;.xls&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (File.Exists(ExcelFileName))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; File.Delete(ExcelFileName);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StreamWriter writer = new StreamWriter(ExcelFileName, false);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DataSet dsBook = new DataSet();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ClsDataBase r = new ClsDataBase();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dsBook = r.GetDataSet(SQL, AdoConn);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int RowsCount = dsBook.Tables[0].Rows.Count;//总行数（不包括头）</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int ColumnsCount = dsBook.Tables[0].Columns.Count;//总列数</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int TableCount = RowsCount / 65535;//要生成的总表数</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int RowRemainder = RowsCount % 65535;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (RowRemainder != 0)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TableCount++;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int NowRow = 0;</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #region 头</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot;&lt;?mso-application progid=\&quot;Excel.Sheet\&quot;?&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot;&lt;Workbook xmlns=\&quot;urn:schemas-microsoft-com:office:spreadsheet\&quot;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; xmlns:o=\&quot;urn:schemas-microsoft-com:office:office\&quot;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; xmlns:x=\&quot;urn:schemas-microsoft-com:office:excel\&quot;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; xmlns:ss=\&quot;urn:schemas-microsoft-com:office:spreadsheet\&quot;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; xmlns:html=\&quot;http://www.w3.org/TR/REC-html40/\&quot;&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;DocumentProperties xmlns=\&quot;urn:schemas-microsoft-com:office:office\&quot;&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;Author&gt;Automated Report Generator Example&lt;/Author&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(string.Format(&quot; &lt;Created&gt;{0}T{1}Z&lt;/Created&gt;&quot;, DateTime.Now.ToString(&quot;yyyy-mm-dd&quot;), DateTime.Now.ToString(&quot;HH:MM:SS&quot;)));</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;Company&gt;揭阳华讯网络服务有限公司&lt;/Company&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;Version&gt;11.6408&lt;/Version&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;/DocumentProperties&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;ExcelWorkbook xmlns=\&quot;urn:schemas-microsoft-com:office:excel\&quot;&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;WindowHeight&gt;8955&lt;/WindowHeight&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;WindowWidth&gt;11355&lt;/WindowWidth&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;WindowTopX&gt;480&lt;/WindowTopX&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;WindowTopY&gt;15&lt;/WindowTopY&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;ProtectStructure&gt;False&lt;/ProtectStructure&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;ProtectWindows&gt;False&lt;/ProtectWindows&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;/ExcelWorkbook&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;Styles&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;Style ss:ID=\&quot;Default\&quot; ss:Name=\&quot;Normal\&quot;&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;Alignment ss:Vertical=\&quot;Bottom\&quot;/&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;Borders/&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;Font/&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;Interior/&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;Protection/&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;/Style&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;Style ss:ID=\&quot;s21\&quot;&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;Alignment ss:Vertical=\&quot;Bottom\&quot; ss:WrapText=\&quot;1\&quot;/&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;/Style&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;/Styles&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #endregion</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #region 内容</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; TableCount; i++)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;Worksheet ss:Name=\&quot;Sheet&quot; + i.ToString() + &quot;\&quot;&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i &lt; TableCount - 1 || RowRemainder == 0)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(string.Format(&quot; &lt;Table ss:ExpandedColumnCount=\&quot;{0}\&quot; ss:ExpandedRowCount=\&quot;{1}\&quot; x:FullColumns=\&quot;1\&quot;&quot;, ColumnsCount.ToString(), &quot;65536&quot;));</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int rowc = RowsCount - i * 65535 + 1;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(string.Format(&quot; &lt;Table ss:ExpandedColumnCount=\&quot;{0}\&quot; ss:ExpandedRowCount=\&quot;{1}\&quot; x:FullColumns=\&quot;1\&quot;&quot;, ColumnsCount.ToString(), rowc.ToString()));</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; x:FullRows=\&quot;1\&quot;&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //生成标题</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot;&lt;Row&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (DataColumn eachCloumn in dsBook.Tables[0].Columns)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.Write(&quot;&lt;Cell ss:StyleID=\&quot;s21\&quot;&gt;&lt;Data ss:Type=\&quot;String\&quot;&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.Write(eachCloumn.ColumnName.ToString());</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot;&lt;/Data&gt;&lt;/Cell&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot;&lt;/Row&gt;&quot;);</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j &lt; 65536; j++)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (NowRow == RowsCount - 1)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DataRow eachRow = dsBook.Tables[0].Rows[NowRow];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot;&lt;Row&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int currentRow = 0; currentRow != ColumnsCount; currentRow++)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.Write(&quot;&lt;Cell ss:StyleID=\&quot;s21\&quot;&gt;&lt;Data ss:Type=\&quot;String\&quot;&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.Write(eachRow[currentRow].ToString());</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot;&lt;/Data&gt;&lt;/Cell&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot;&lt;/Row&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NowRow++;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;/Table&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;WorksheetOptions xmlns=\&quot;urn:schemas-microsoft-com:office:excel\&quot;&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;Selected/&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;Panes&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &nbsp;&lt;Pane&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &nbsp; &lt;Number&gt;3&lt;/Number&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &nbsp; &lt;ActiveRow&gt;1&lt;/ActiveRow&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &nbsp;&lt;/Pane&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;/Panes&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;ProtectObjects&gt;False&lt;/ProtectObjects&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &nbsp; &lt;ProtectScenarios&gt;False&lt;/ProtectScenarios&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;/WorksheetOptions&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot; &lt;/Worksheet&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.WriteLine(&quot;&lt;/Workbook&gt;&quot;);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #endregion</div><div>&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.Close();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ExcelFileName;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</div><div>}</div><div>&nbsp;</div>]]></description><category>技术文章</category><comments>http://blog.careff.com/post/375.html#comment</comments><wfw:commentRss>http://blog.careff.com/feed.asp?cmt=375</wfw:commentRss></item><item><title> 2013年2月Tiobe编程语言排行榜发布</title><author>a@b.com (admin)</author><link>http://blog.careff.com/post/373.html</link><pubDate>Wed, 03 Jul 2013 09:18:02 +0800</pubDate><guid>http://blog.careff.com/post/373.html</guid><description><![CDATA[<p>&nbsp;<span style="font-family: 宋体; font-size: 14px; line-height: 25px;">2013年2月Tiobe编程语言排行榜发布！本月</span><a class="channel_keylink" href="http://java.chinaitlab.com/" target="_blank" style="font-family: 宋体; font-size: 14px; margin: 0px; padding: 0px; word-wrap: break-word; text-decoration: none; color: rgb(0, 0, 255); line-height: 22px;">Java</a><span style="font-family: 宋体; font-size: 14px; line-height: 25px;">与C位置互换，前三甲分别为</span><a class="channel_keylink" href="http://java.chinaitlab.com/" target="_blank" style="font-family: 宋体; font-size: 14px; margin: 0px; padding: 0px; word-wrap: break-word; text-decoration: none; color: rgb(0, 0, 255); line-height: 22px;">Java</a><span style="font-family: 宋体; font-size: 14px; line-height: 25px;">、C、Objective-C。</span></p><p style="margin: 10px 0px 0px; padding: 0px; word-wrap: break-word; font-family: 宋体; font-size: 14px; line-height: 25px;">Java失去编程宝座已有10个月，如今再次夺得桂冠，这将得益于Android 手机领域的大力发展，较上半年上升2.03%的份额。</p><p style="margin: 10px 0px 0px; padding: 0px; word-wrap: break-word; font-family: 宋体; font-size: 14px; line-height: 25px;">作为Java的爱好者，也许你会大吃一惊，因为这个月Java再次重返榜首位置，Java爱好者苦等好久了吧。</p><p style="margin: 10px 0px 0px; padding: 0px; word-wrap: break-word; font-family: 宋体; font-size: 14px; line-height: 25px;">其他值得关注的是，Python再度上涨，较上半年上升1.07% 的份额。Python可与PHP相媲美，紧随其后，或许它将成为最流行的解释性语言。</p><p style="margin: 10px 0px 0px; padding: 0px; word-wrap: break-word; font-family: 宋体; font-size: 14px; line-height: 25px;"><strong style="margin: 0px; padding: 0px; word-wrap: break-word;">前20名榜单排行榜：</strong></p><p style="margin: 10px 0px 0px; padding: 0px; word-wrap: break-word; font-family: 宋体; font-size: 14px; line-height: 25px; text-align: center;"><img src="/upload/20130218145420423.jpg" alt="" /></p><p style="margin: 10px 0px 0px; padding: 0px; word-wrap: break-word; font-family: 宋体; font-size: 14px; line-height: 25px;"><strong style="margin: 0px; padding: 0px; word-wrap: break-word;">前10名编程语言走势图：</strong></p><p style="margin: 10px 0px 0px; padding: 0px; word-wrap: break-word; font-family: 宋体; font-size: 14px; line-height: 25px; text-align: center;"><a href="http://java.chinaitlab.com/UploadFiles_8734/201302/20130218145421752.jpg" target="_blank" style="margin: 0px; padding: 0px; word-wrap: break-word; text-decoration: none; color: rgb(51, 51, 51);"><img border="0" src="http://java.chinaitlab.com/UploadFiles_8734/201302/20130218145421752.jpg" style="margin: 0px; padding: 0px; word-wrap: break-word;" alt="" /></a></p><p><img onload="ResizeImage(this,520)" src="http://blog.careff.com/zb_users/upload/20130218145420423.jpg" alt="" title="" /></p>]]></description><category>技术文章</category><comments>http://blog.careff.com/post/373.html#comment</comments><wfw:commentRss>http://blog.careff.com/feed.asp?cmt=373</wfw:commentRss></item><item><title>net混淆、反编译工具调查</title><author>a@b.com (admin)</author><link>http://blog.careff.com/post/354.html</link><pubDate>Tue, 26 Feb 2013 12:34:09 +0800</pubDate><guid>http://blog.careff.com/post/354.html</guid><description><![CDATA[<p>&nbsp;</p><h1 class="postTitle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 5px; font-size: 12px; font-weight: normal; float: left; line-height: 1.5em; width: 718px; clear: both; color: rgb(85, 85, 85); font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; text-align: left; background-color: rgb(245, 248, 250); "><a id="cb_post_title_url" class="postTitle2" href="http://www.cnblogs.com/2018/archive/2010/05/14/1735781.html" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(245, 100, 0); text-decoration: none; font-family: 微软雅黑, 黑体, Arial; font-size: 18px; ">.net混淆、反编译工具调查</a></h1><div class="clear" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; clear: both; color: rgb(85, 85, 85); font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; line-height: normal; text-align: left; background-color: rgb(245, 248, 250); ">&nbsp;</div><div class="postBody" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 2px; padding-bottom: 5px; padding-left: 5px; line-height: 2; color: rgb(85, 85, 85); border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: black; font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; text-align: left; background-color: rgb(245, 248, 250); "><div id="cnblogs_post_body" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-break: normal !important; "><h5 style="margin-top: 15px; margin-right: auto; margin-bottom: 2px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; color: rgb(51, 51, 51); ">常用的工具列表[比较常见的]</h5><table cellpadding="0" cellspacing="0" border="1" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); ">    <tbody style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="568" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">混淆器、加密</p>            </td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="168" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Dotfuscator</p>            </td>            <td width="400" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">VS默认带的工具，不过是个社区版</p>            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">强度不大</p>            </td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="168" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">dotNET Reactor</p>            </td>            <td width="400" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">使用了NativeCode 和混淆的形式</p>            </td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="168" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Xenocode Postbuild</p>            </td>            <td width="400" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">专业工具</p>            </td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="168" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">{smartassembly}.Setup.msi</p>            </td>            <td width="400" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">&nbsp;</td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="568" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">反编译工具</p>            </td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="168" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Reflector</p>            </td>            <td width="400" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">最富盛名的一个工具，很多插件都开源</p>            </td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="168" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Xenocode Fox</p>            </td>            <td width="400" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">专业工具，商业版本</p>            </td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="168" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">ildasm</p>            </td>            <td width="400" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Vs带的工具</p>            </td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="568" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">组件合并、虚拟工具:方便软件发布的工具,如合并多个dll文件等</p>            </td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="168" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Xenocode Studio</p>            </td>            <td width="400" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">将所有的组件和涉及的.net框架都可打在一个执行文件中，简化了部署和安装</p>            </td>        </tr>        <tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">            <td width="168" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Dotfuscator</p>            </td>            <td width="400" valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); border-collapse: collapse; word-break: normal !important; ">            <p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">组件合并</p>            </td>        </tr>    </tbody></table><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">[处理时需要注意选择是库文件还是执行文件,两个方式不太一样,发布出去前需要用以上的反编译验证是否正确的处理了，可以起到保护的作用]</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">工具可找到名称</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">DotNETReactor.rar</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Xenocode+Postbuild+2010+for+.NET.rar：可用</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Xenocode_Virtual_Application_Studio_ISV_Edition.msi：windows 7下使用存在问题，其它正常</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">XenocodeFox2007_v5.2_build_6675.rar：fox可用，其它的需要联网</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">{smartassembly}.Setup.msi</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">dotfuscatorpe42_rt20.zip: 专业版本,和vs自带的版本功能基本一样，不过是专业版</p><h5 style="margin-top: 15px; margin-right: auto; margin-bottom: 2px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; color: rgb(51, 51, 51); ">网络资料</h5><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">http://www.cnblogs.com/jason_z/archive/2009/10/19/1585804.html</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a href="http://www.cnblogs.com/Jason_z/archive/2009/10/19/1585804.html" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(85, 85, 85); ">分享：几款代码混淆器（DotFuscator, .NET Reactor, xenocode）</a></p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">在介绍工具之前，我需要说明几点：</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">1.如果你编写的软件不涉及商业用途的话，本着开源的思想，本人不推荐使用代码混淆器</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">2.使用代码混淆器存在一定的风险，在使用前最好做好相关代码备份</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">3.凡是需要序列化成二进制的代码，是不能用混淆器的。混淆后的代码将不能正常序列化！[类的域名等混淆后，序列化后不一样]</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">DotFuscator是VS里面一个自带的代码混淆器，VS&mdash;&mdash;工具&mdash;&mdash;Dotfuscator Community Edition</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">具体使用方法，及产生的混淆效果，可参考：<a href="http://blog.csdn.net/netjxz/archive/2006/12/12/1439866.aspx" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(85, 85, 85); ">http://blog.csdn.net/netjxz/archive/2006/12/12/1439866.aspx</a></p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">.NET Reactor，这个非常小巧，免安装，而且不需要注册。他只是将代码换成随机码，但是混淆后的代码都能正常使用。</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">具体的使用方法都比较简单，下载地址：<a href="http://files.cnblogs.com/ghost79/DotNETReactor.rar" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(85, 85, 85); ">http://files.cnblogs.com/ghost79/DotNETReactor.rar</a></p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">xeoncode 则是一款相对更加专业的代码混淆软件，混淆后的程序集可以屏蔽一些反编译工具（Ildasm之类的），具体使用方法：</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">用法一：&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 1、导入要加密的dotNET程序或assembly文件(.dll/.exe)&nbsp;&nbsp;&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 2、选择第二个选项卡&ldquo;Protect&rdquo;&nbsp;&nbsp;&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 3、点击&ldquo;Select&nbsp;&nbsp; Pattern&rdquo;&nbsp;&nbsp;&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 4、选中所有&ldquo;Object&nbsp;&nbsp; Type&rdquo;和所有&ldquo;Visiblility&rdquo;&nbsp;&nbsp;&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 5、&ldquo;Action&rdquo;选择&ldquo;Do&nbsp;&nbsp; not&nbsp;&nbsp; obfuscate&rdquo;，Apply，把所有的内容都设为不进行混淆&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 6、&ldquo;Action&rdquo;选择&ldquo;Obfuscate&rdquo;，&ldquo;Visibility&rdquo;只选择&ldquo;Private&rdquo;，Apply&nbsp;&nbsp;&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 7、右下角按下&ldquo;XenoCode&nbsp;&nbsp; Assemblies&rdquo;，导出混淆后的文件&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />用法二：&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 1、选中Application标签&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 2、点击Add按钮，加载要混淆的Dll、Exe文件&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 3、如果是Dll文件则选中Preset列表框中的第二项，反之选中第一项&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 4、点击Apply按钮&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 5、选中Protect标签&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 6、选中Supress&nbsp;&nbsp; other&nbsp;&nbsp; reflection&nbsp;&nbsp; tools复选框&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 7、点击Select&nbsp;&nbsp; String按钮进行设置&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 8、点击XenoCode按钮完成混淆工作&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp; 9、再换一个文件进行混合到全部文件混淆完毕为止！</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">以上摘自网络，仅供参考。</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">2009最新版，注册的license也在压缩包里</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">下载地址：<a href="http://d.download.csdn.net/down/1702658/Danny_Su" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(85, 85, 85); ">http://d.download.csdn.net/down/1702658/Danny_Su</a></p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">http://seednet.to/html2/v5199.htm</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Xenocode R Virtual Application Studio 可讓您在虛擬包中定制和預先配置您的</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">桌面應用程式，它可以立刻在任何地方進行部署。</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Virtual Application Studio的新特性：</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">在一個單一的可執行檔中部署複雜的應用軟體通過在一個單一預先配置的、能在任</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">何地方立即運行的可執行檔中的部署，大大簡化了應用程式的部署和維護。消除安</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">裝步驟、用戶配置、DLL hell或丟失的關聯。運行Xenocode虛擬應用程式不需要代</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">理或設備驅動。不具備基本設備改變的流將您的虛擬應用程式放在標準的網路共用</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">或網站上，使其能立即供用戶使用。不需要Active Directory、流伺服器或其他設</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">備。執行.NET和Java應用程式不需要運行時的安裝通過一個點擊就能將可分配的運</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">行控制項嵌入到您的虛擬應用程式中。虛擬應用程式能在沒有運行庫（或其他運行</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">庫版本）的情況下在主機上正常運行。 在Vista上運行遺留應用程式在Xenocode虛</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">擬作業系統上的執行消除了在 Windows Vista上與部署遺留應用程式相關的相容性</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">問題。 獨特的Internet Explorer 6仿真模式允許基於IE-6的應用程式被部署在Vi</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">sta本地桌面上。 在鎖定桌面上執行Xenocode虛擬化技術能夠使應用程式避免訪問</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">保密的檔系統和註冊表資源，使其在一個鎖定的桌面上執行。當在 Windows Vista</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">上部署時，避免UAC的提示和應用程式故障。 全用戶模式執行Xenocode虛擬化技術</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">並不依賴於任何代理或設備驅動程式的支援以及消除所需的用戶端安裝或管理的許</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">可權。 可立即在鎖定的桌面和自助終端上運行。 前所未有的虛擬化性能與整機虛</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">擬化系統不同，Xenocode應用程式虛擬化技術能使虛擬的應用程式的執行速度基本</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">與應用程式在本地運行的速度相同。在虛擬應用程式二進位檔中不包含作業系統控</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">制項或檔，這在最大程度上減少了佔用空間。透明的資料壓縮進一步降低了有效載</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">荷的大小。充分利用現有的管理工具Xenocode的獨立於代理和伺服器的設計能讓虛</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">擬的應用程式簡單地整合到現有的應用程式管理設備中，包括Microsoft SMS、LAN</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Desk管理套包、Novell ZENworks以及Symantec AppStream 。虛擬應用程式能作為</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">獨立的EXE檔或通過使用MSI安裝包進行部署。</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a href="http://www.crazycoder.cn/BlogDigest/Article76985.html" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(85, 85, 85); ">http://www.crazycoder.cn/BlogDigest/Article76985.html</a></p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">破解版下载地址：</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a href="http://download.csdn.net/source/1733855" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(85, 85, 85); ">http://download.csdn.net/source/1733855</a></p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">安装后，按照下面的步骤注册</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&lt;LicenseCertificate version=&quot;2&quot; publisher=&quot;Xenocode&quot;&gt;</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&lt;LicenseType&gt;Retail&lt;/LicenseType&gt;</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&lt;LicenseModel&gt;Site&lt;/LicenseModel&gt;</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&lt;ProductCode&gt;ALL&lt;/ProductCode&gt;</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&lt;LicenseeName&gt;Danny Su&lt;/LicenseeName&gt;</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&lt;AccountNumber&gt;74149478E1G67EDCFD64CGF054868C64&lt;/AccountNumber&gt;</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&lt;Signature&gt;</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">ef6033cc7aabadd60994281c92373b321a41137e45c0e920ef0e6f175c641f25</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">284b6211033128e7cf6330908aca22278592abe2aad98e9616ca65130c2c6c0a</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">d5144a04913d35332f837959168d485324fd6c55f4473317da156625a00af262</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">df019e69bf2c833136991e8989107bbce794c635cf3294476636d2355479f25f</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&lt;/Signature&gt;</p><p style="margin-top: 10px; margin-right: auto; margin-bottom: 10px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&lt;/LicenseCertificate&gt;</p></div><div id="MySignature" style="margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</div><div class="clear" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; clear: both; ">&nbsp;</div><div id="blog_post_info_block" style="margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><div id="blog_post_info" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><div id="BlogPostCategory" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">分类:&nbsp;<a href="http://www.cnblogs.com/2018/category/249772.html" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(85, 85, 85); ">工具</a></div></div></div></div>]]></description><category>技术文章</category><comments>http://blog.careff.com/post/354.html#comment</comments><wfw:commentRss>http://blog.careff.com/feed.asp?cmt=354</wfw:commentRss></item><item><title> NET可以通过多种方式实现zip的压缩和解压</title><author>a@b.com (admin)</author><link>http://blog.careff.com/post/350.html</link><pubDate>Wed, 29 Aug 2012 16:43:13 +0800</pubDate><guid>http://blog.careff.com/post/350.html</guid><description><![CDATA[<p>&nbsp;<span class="Apple-style-span" style="font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; font-size: 13px; background-color: rgb(254, 254, 242); ">&nbsp;&nbsp;&nbsp;&nbsp; 在.NET可以通过多种方式实现zip的压缩和解压：1、使用System.IO.Packaging；2、使用第三方类库；3、通过 System.IO.Compression 命名空间中新增的ZipArchive、ZipFile等类实现。<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp; 一、使用System.IO.Packaging压缩和解压</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://msdn.microsoft.com/zh-cn/library/system.io.packaging.package.aspx" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(7, 93, 179); text-decoration: underline; ">Package</a>为一个抽象类，可用于将对象组织到定义的物理格式的单个实体中，从而实现可移植性与高效访问。ZIP 文件是<a href="http://msdn.microsoft.com/zh-cn/library/system.io.packaging.package.aspx" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(7, 93, 179); text-decoration: underline; ">Package</a>的主物理格式。 其他<a href="http://msdn.microsoft.com/zh-cn/library/system.io.packaging.package.aspx" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(7, 93, 179); text-decoration: underline; ">Package</a>实现可以使用其他物理格式（如 XML 文档、数据库或 Web 服务。与文件系统类似，在分层组织的文件夹和文件中引用&nbsp;<a href="http://msdn.microsoft.com/zh-cn/library/system.io.packaging.package.aspx" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(7, 93, 179); text-decoration: underline; ">Package</a>&nbsp;中包含的项。虽然&nbsp;<a href="http://msdn.microsoft.com/zh-cn/library/system.io.packaging.package.aspx" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(7, 93, 179); text-decoration: underline; ">Package</a>&nbsp;是抽象类，但&nbsp;<a href="http://msdn.microsoft.com/zh-cn/library/system.io.packaging.package.open.aspx" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(7, 93, 179); text-decoration: underline; ">Package.Open</a>&nbsp;方法默认使用&nbsp;<a href="http://msdn.microsoft.com/zh-cn/library/system.io.packaging.zippackage.aspx" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(7, 93, 179); text-decoration: underline; ">ZipPackage</a>&nbsp;派生类。</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp; System.IO.Packaging在WindowsBase.dll程序集下，使用时需要添加对WindowsBase的引用。</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp; 1、将整个文件夹压缩成zip</p><div class="cnblogs_code" style="margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 12px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: auto; overflow-y: auto; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; font-family: 'Courier New'; "><img id="Code_Open_Image_544543" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; display: inline; " alt="" /><span id="Code_Open_Text_544543" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; display: inline; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;summary&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// Add a folder along with its subfolders to a Package</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;/summary&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;param name=&quot;folderName&quot;&gt;The folder to add&lt;/param&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;param name=&quot;compressedFileName&quot;&gt;The package to create&lt;/param&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;param name=&quot;overrideExisting&quot;&gt;Override exsisitng files&lt;/param&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;returns&gt;&lt;/returns&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">static</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">bool</span> PackageFolder(<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> folderName, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> compressedFileName, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">bool</span> overrideExisting)         {             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">if</span> (folderName.EndsWith(@&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">\</span>&quot;))                 folderName = folderName.Remove(folderName.Length - 1);             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">bool</span> result = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">false</span>;             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">if</span> (!Directory.Exists(folderName))             {                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">return</span> result;             }              <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">if</span> (!overrideExisting &amp;&amp; File.Exists(compressedFileName))             {                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">return</span> result;             }             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">try</span>             {                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">using</span> (Package package = Package.Open(compressedFileName, FileMode.Create))                 {                     var fileList = Directory.EnumerateFiles(folderName, &quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">*</span>&quot;, SearchOption.AllDirectories);                     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">foreach</span> (<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> fileName <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">in</span> fileList)                     {                                                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 128, 0); ">//The path in the package is all of the subfolders after folderName</span>                         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> pathInPackage;                         pathInPackage = Path.GetDirectoryName(fileName).Replace(folderName, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span>.Empty) + &quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">/</span>&quot; + Path.GetFileName(fileName);                          Uri partUriDocument = PackUriHelper.CreatePartUri(<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> Uri(pathInPackage, UriKind.Relative));                         PackagePart packagePartDocument = package.CreatePart(partUriDocument,&quot;&quot;, CompressionOption.Maximum);                         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">using</span> (FileStream fileStream = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> FileStream(fileName, FileMode.Open, FileAccess.Read))                         {                             fileStream.CopyTo(packagePartDocument.GetStream());                         }                     }                 }                 result = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">true</span>;             }             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">catch</span> (Exception e)             {                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">throw</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> Exception(&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">Error zipping folder </span>&quot; + folderName, e);             }                         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">return</span> result;         }</span></pre></div><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2、将单个文件添加到zip文件中</p><div class="cnblogs_code" style="margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 12px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: auto; overflow-y: auto; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; font-family: 'Courier New'; "><img id="Code_Open_Image_866528" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; display: inline; " alt="" /><span id="Code_Open_Text_866528" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; display: inline; ">       <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;summary&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// Compress a file into a ZIP archive as the container store</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;/summary&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;param name=&quot;fileName&quot;&gt;The file to compress&lt;/param&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;param name=&quot;compressedFileName&quot;&gt;The archive file&lt;/param&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;param name=&quot;overrideExisting&quot;&gt;override existing file&lt;/param&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;returns&gt;&lt;/returns&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">static</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">bool</span> PackageFile(<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> fileName, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> compressedFileName, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">bool</span> overrideExisting)         {             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">bool</span> result = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">false</span>;              <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">if</span> (!File.Exists(fileName))             {                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">return</span> result;             }              <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">if</span> (!overrideExisting &amp;&amp; File.Exists(compressedFileName))             {                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">return</span> result;             }              <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">try</span>             {                 Uri partUriDocument = PackUriHelper.CreatePartUri(<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> Uri(Path.GetFileName(fileName), UriKind.Relative));                                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">using</span> (Package package = Package.Open(compressedFileName, FileMode.OpenOrCreate))                 {                     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">if</span> (package.PartExists(partUriDocument))                     {                         package.DeletePart(partUriDocument);                     }                       PackagePart packagePartDocument = package.CreatePart(partUriDocument, &quot;&quot;, CompressionOption.Maximum);                     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">using</span> (FileStream fileStream = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> FileStream(fileName, FileMode.Open, FileAccess.Read))                     {                         fileStream.CopyTo(packagePartDocument.GetStream());                     }                 }                 result = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">true</span>;             }             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">catch</span> (Exception e)             {                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">throw</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> Exception(&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">Error zipping file </span>&quot; + fileName, e);             }                          <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">return</span> result;         }</span></pre></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3、zip文件解压</p><div class="cnblogs_code" style="margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 12px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: auto; overflow-y: auto; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; font-family: 'Courier New'; "><img id="Code_Open_Image_445529" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; display: inline; " alt="" /><span id="Code_Open_Text_445529" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; display: inline; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;summary&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// Extract a container Zip. NOTE: container must be created as Open Packaging Conventions (OPC) specification</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;/summary&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;param name=&quot;folderName&quot;&gt;The folder to extract the package to&lt;/param&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;param name=&quot;compressedFileName&quot;&gt;The package file&lt;/param&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;param name=&quot;overrideExisting&quot;&gt;override existing files&lt;/param&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(128, 128, 128); ">/// &lt;returns&gt;&lt;/returns&gt;</span>         <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">static</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">bool</span> UncompressFile(<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> folderName, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> compressedFileName, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">bool</span> overrideExisting)         {             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">bool</span> result = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">false</span>;             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">try</span>             {                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">if</span> (!File.Exists(compressedFileName))                 {                     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">return</span> result;                 }                  DirectoryInfo directoryInfo = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> DirectoryInfo(folderName);                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">if</span> (!directoryInfo.Exists)                     directoryInfo.Create();                  <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">using</span> (Package package = Package.Open(compressedFileName, FileMode.Open, FileAccess.Read))                 {                     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">foreach</span> (PackagePart packagePart <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">in</span> package.GetParts())                     {                         ExtractPart(packagePart, folderName, overrideExisting);                     }                 }                  result = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">true</span>;             }             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">catch</span> (Exception e)             {                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">throw</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> Exception(&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">Error unzipping file </span>&quot; + compressedFileName, e);             }                          <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">return</span> result;         }          <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">static</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">void</span> ExtractPart(PackagePart packagePart, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> targetDirectory, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">bool</span> overrideExisting)         {             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> stringPart = targetDirectory + HttpUtility.UrlDecode(packagePart.Uri.ToString()).Replace('\\', '/');              <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">if</span> (!Directory.Exists(Path.GetDirectoryName(stringPart)))                 Directory.CreateDirectory(Path.GetDirectoryName(stringPart));              <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">if</span> (!overrideExisting &amp;&amp; File.Exists(stringPart))                 <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">return</span>;             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">using</span> (FileStream fileStream = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> FileStream(stringPart, FileMode.Create))             {                 packagePart.GetStream().CopyTo(fileStream);             }         }</span></pre></div><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 使用<a href="http://msdn.microsoft.com/zh-cn/library/system.io.packaging.package.aspx" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(7, 93, 179); text-decoration: underline; ">Package</a>压缩文件会在zip文件自动生成[Content_Type].xml，用来描述zip文件解压支持的文件格式。</p><div class="cnblogs_code" style="margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 12px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: auto; overflow-y: auto; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; font-family: 'Courier New'; "><img id="Code_Open_Image_145135" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; display: inline; " alt="" /><span id="Code_Open_Text_145135" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; display: inline; ">&lt;?xml version=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">1.0</span>&quot; encoding=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">utf-8</span>&quot; ?&gt;  &lt;Types xmlns=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">http://schemas.openxmlformats.org/package/2006/content-types</span>&quot;&gt;     &lt;Default Extension=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">vsixmanifest</span>&quot; ContentType=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">text/xml</span>&quot; /&gt;      &lt;Default Extension=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">dll</span>&quot; ContentType=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">application/octet-stream</span>&quot; /&gt;      &lt;Default Extension=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">png</span>&quot; ContentType=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">application/octet-stream</span>&quot; /&gt;      &lt;Default Extension=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">txt</span>&quot; ContentType=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">text/plain</span>&quot; /&gt;      &lt;Default Extension=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">pkgdef</span>&quot; ContentType=&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">text/plain</span>&quot; /&gt;  &lt;/Types&gt;</span></pre></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 同样，如果zip文件不包含[Content_Type].xml文件，或者[Content_Type].xml文件不包含所对应扩展名的描述（手动添加的[Content_Type].xml也是可以），将无法解压文件。</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 二、使用第三方类库</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip的压缩和解压使用比较的有<a href="http://www.icsharpcode.net/opensource/sharpziplib/" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(7, 93, 179); text-decoration: underline; ">SharpZipLib</a>和<a href="http://dotnetzip.codeplex.com/" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(7, 93, 179); text-decoration: underline; ">DotNetZip</a>。</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1、SharpZipLib，也称为&ldquo;#ziplib&rdquo;，基于GPL开源，支持Zip，GZip，Tar和BZip2的压缩和解压缩。</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 支持.NET 1.1,NET 2.0（3.5、4.0）.</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; （1）zip压缩</p><div class="cnblogs_code" style="margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 12px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: auto; overflow-y: auto; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; font-family: 'Courier New'; "><img id="Code_Open_Image_895137" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; display: inline; " alt="" /><span id="Code_Open_Text_895137" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; display: inline; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">public</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">static</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">void</span> Zip(<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> SrcFile, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> DstFile, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">int</span> BufferSize) {     FileStream fileStreamIn = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> FileStream 		(SrcFile, FileMode.Open, FileAccess.Read);     FileStream fileStreamOut = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> FileStream 		(DstFile, FileMode.Create, FileAccess.Write);     ZipOutputStream zipOutStream = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> ZipOutputStream(fileStreamOut);     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">byte</span>[] buffer = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">byte</span>&lt;buffersize /&gt;;     ZipEntry entry = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> ZipEntry(Path.GetFileName(SrcFile));     zipOutStream.PutNextEntry(entry);     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">int</span> size;     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">do</span>     {         size = fileStreamIn.Read(buffer, 0, buffer.Length);         zipOutStream.Write(buffer, 0, size);     } <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">while</span> (size &gt; 0);     zipOutStream.Close();     fileStreamOut.Close();     fileStreamIn.Close(); }</span></pre></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; （2）解压zip</p><div class="cnblogs_code" style="margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 12px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: auto; overflow-y: auto; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; font-family: 'Courier New'; "><img id="Code_Open_Image_190863" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; display: inline; " alt="" /><span id="Code_Open_Text_190863" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; display: inline; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">public</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">static</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">void</span> UnZip(<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> SrcFile, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> DstFile, <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">int</span> BufferSize) {     FileStream fileStreamIn = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> FileStream 		(SrcFile, FileMode.Open, FileAccess.Read);     ZipInputStream zipInStream = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> ZipInputStream(fileStreamIn);     ZipEntry entry = zipInStream.GetNextEntry();     FileStream fileStreamOut = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> FileStream 		(DstFile + @&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">\</span>&quot; + entry.Name, FileMode.Create, FileAccess.Write);     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">int</span> size;     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">byte</span>[] buffer = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">byte</span>&lt;buffersize /&gt;;     <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">do</span>     {         size = zipInStream.Read(buffer, 0, buffer.Length);         fileStreamOut.Write(buffer, 0, size);     } <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">while</span> (size &gt; 0);     zipInStream.Close();     fileStreamOut.Close();     fileStreamIn.Close(); }</span></pre></div><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2、DotNetLib，是基于&rdquo;WS-PL&rdquo;开源，使用比较简单<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp; (1)压缩</p><div class="cnblogs_code" style="margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 12px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: auto; overflow-y: auto; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; font-family: 'Courier New'; "><img id="Code_Open_Image_752701" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; display: inline; " alt="" /><span id="Code_Open_Text_752701" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; display: inline; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">using</span> (ZipFile zip = <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">new</span> ZipFile())   {     zip.AddFile(&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">ReadMe.txt</span>&quot;);     zip.AddFile(&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">7440-N49th.png</span>&quot;);     zip.AddFile(&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">2008_Annual_Report.pdf</span>&quot;);             zip.Save(&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">Archive.zip</span>&quot;);   }</span></pre></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp;&nbsp; （2）解压</p><div class="cnblogs_code" style="margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 12px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: auto; overflow-y: auto; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; font-family: 'Courier New'; "><img id="Code_Open_Image_896044" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; display: inline; " alt="" /><span id="Code_Open_Text_896044" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; display: inline; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">private</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">void</span> MyExtract()   {       <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> zipToUnpack = &quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">C1P3SML.zip</span>&quot;;       <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> unpackDirectory = &quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">Extracted Files</span>&quot;;       <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">using</span> (ZipFile zip1 = ZipFile.Read(zipToUnpack))       {           <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 128, 0); ">// here, we extract every entry, but we could extract conditionally</span>           <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 128, 0); ">// based on entry name, size, date, checkbox status, etc.  </span>           <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">foreach</span> (ZipEntry e <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">in</span> zip1)           {             e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);           }        }     }</span></pre></div><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; line-height: 1.5; color: rgb(0, 0, 0); font-size: 13px; ">&nbsp;&nbsp;&nbsp; 三、在.NET 4.5使用ZipArchive、ZipFile等类压缩和解压</p><div class="cnblogs_code" style="margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 12px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: auto; overflow-y: auto; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; font-family: 'Courier New'; "><img id="Code_Open_Image_204566" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; display: inline; " alt="" /><span id="Code_Open_Text_204566" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; display: inline; ">        <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">static</span> <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">void</span> Main(<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span>[] args)         {             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> ZipPath = @&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">c:\users\exampleuser\start.zip</span>&quot;;             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> ExtractPath = @&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">c:\users\exampleuser\extract</span>&quot;;             <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">string</span> NewFile = @&quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">c:\users\exampleuser\NewFile.txt</span>&quot;;              <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(0, 0, 255); ">using</span> (ZipArchive Archive = ZipFile.Open(ZipPath, ZipArchiveMode.Update))             {                 Archive.CreateEntryFromFile(NewFile, &quot;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; color: rgb(139, 0, 0); ">NewEntry.txt</span>&quot;);                 Archive.ExtractToDirectory(ExtractPath);             }          }</span></pre><div><span id="Code_Open_Text_204566" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; font-size: 12px; line-height: 1.5; display: inline; "><br /></span></div></div></span></p>]]></description><category>技术文章</category><comments>http://blog.careff.com/post/350.html#comment</comments><wfw:commentRss>http://blog.careff.com/feed.asp?cmt=350</wfw:commentRss></item><item><title>序列化和反序列化</title><author>a@b.com (admin)</author><link>http://blog.careff.com/post/349.html</link><pubDate>Wed, 29 Aug 2012 10:10:51 +0800</pubDate><guid>http://blog.careff.com/post/349.html</guid><description><![CDATA[<p><span class="Apple-style-span" style="font-family: simsun; font-size: 14px; line-height: 23px; ">序列化&nbsp;<br />//序列化&nbsp;<br />public &nbsp; &nbsp; byte[] &nbsp; SerializeObject(object &nbsp; pObj)&nbsp;<br />{&nbsp;<br />if(pObj &nbsp; == &nbsp; null)&nbsp;<br />return &nbsp; null;&nbsp;<br />System.IO.MemoryStream &nbsp; _memory &nbsp; = &nbsp; new &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.IO.MemoryStream();<br />BinaryFormatter &nbsp; formatter &nbsp; = &nbsp; new &nbsp; BinaryFormatter();&nbsp;<br />formatter.Serialize(_memory,pObj);&nbsp;<br />_memory.Position &nbsp; = &nbsp; 0;&nbsp;<br />byte[] &nbsp; read &nbsp; = &nbsp; new &nbsp; byte[_memory.Length];&nbsp;<br />_memory.Read(read,0,read.Length);&nbsp;<br />_memory.Close();&nbsp;<br />return &nbsp; read;&nbsp;<br />}</span></p><p>&nbsp;</p><p>&nbsp;<span class="Apple-style-span" style="font-family: simsun; font-size: 14px; line-height: 23px; ">如果你只是直接将信息保存到数据库,沒有必要序列化&nbsp;<br />string &nbsp; conn_str &nbsp; = &nbsp; System.Configuration.ConfigurationSettings.AppSettings[ &quot;conn_str &quot;].ToString();&nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string &nbsp; sREQUEST_ID &nbsp; = &nbsp; Session[ &quot;REQUEST_ID &quot;].ToString();&nbsp;<br />OleDbConnection &nbsp; cn &nbsp; = &nbsp; new &nbsp; OleDbConnection(conn_str);&nbsp;<br />cn.Open();&nbsp;<br />OleDbCommand &nbsp; cmd &nbsp; = &nbsp; new &nbsp; OleDbCommand( &quot;UPDATE &nbsp; REQUEST_MASTER &nbsp; SET &nbsp; REQUEST_FILE=? &nbsp; WHERE &nbsp; REQUEST_ID= &quot; &nbsp; +int.Parse(sREQUEST_ID),cn);&nbsp;<br />cmd.Parameters.Add( &quot;REQUEST_FILE &quot;,OleDbType.Binary);	<br /><br />if(!sFileName1.Equals( &quot; &quot;))&nbsp;<br />{&nbsp;<br />try&nbsp;<br />{&nbsp;<br />FileStream &nbsp; fs &nbsp; = &nbsp; new &nbsp; FileStream(Path &nbsp; +sFileName1, &nbsp; FileMode.OpenOrCreate, &nbsp; FileAccess.Read);&nbsp;<br />byte[] &nbsp; MyData1= &nbsp; new &nbsp; byte[fs.Length];&nbsp;<br />fs.Read(MyData1, &nbsp; 0, &nbsp; System.Convert.ToInt32(fs.Length));&nbsp;<br />fs.Close();&nbsp;<br />cmd.Parameters[ &quot;REQUEST_FILE &quot;].Value &nbsp; = &nbsp; MyData1;&nbsp;<br />}&nbsp;<br />catch(Exception &nbsp; err)&nbsp;<br />{&nbsp;<br />string &nbsp; s &nbsp; = &nbsp; err.Message;&nbsp;<br />}&nbsp;<br />}&nbsp;<br />else&nbsp;<br />{&nbsp;<br />cmd.Parameters[ &quot;REQUEST_FILE &quot;].Value &nbsp; = &nbsp; MyData;&nbsp;<br />}&nbsp;<br />try &nbsp;&nbsp;<br />{&nbsp;<br /><br />cmd.ExecuteNonQuery(); &nbsp;&nbsp;<br />}	<br />catch(Exception &nbsp; e1)&nbsp;<br />{&nbsp;<br />}&nbsp;<br />finally&nbsp;<br />{&nbsp;<br />cn.Close();&nbsp;<br />}</span></p>]]></description><category>技术文章</category><comments>http://blog.careff.com/post/349.html#comment</comments><wfw:commentRss>http://blog.careff.com/feed.asp?cmt=349</wfw:commentRss></item></channel></rss>
