七步

爱生活,爱七步...
随笔 - 2, 文章 - 2, 评论 - 0, 引用 - 0
数据加载中……

2008年3月31日

SharpZipLib使用递归压缩文件夹

 

using   System;     
using   ICSharpCode.SharpZipLib.Zip;   
using   System.IO;

namespace feixinBackUp   
  
{   
  
///   <summary>   
  
///   压缩解压类  
  
///   </summary>   

  public   class   Myzip      
  
{   
      ZipOutputStream zos
=null;   
      
string strBaseDir="";

      
public void dlZipDir(string[] args)
      
{   
      zos 
= new ZipOutputStream(File.Create(args[1]));
      zos.Password 
="";//设置压缩文件密码
      strBaseDir = args[0]+ "\\";   
      addZipEntry(strBaseDir);   
      zos.Finish();   
      zos.Close();   
      }
   
    
      
void addZipEntry(string PathStr)
      
{   

          DirectoryInfo di
=new DirectoryInfo(PathStr);   
          
foreach(DirectoryInfo item in di.GetDirectories())
          
{  
              addZipEntry(item.FullName);   
          }
   
          
foreach(FileInfo item in di.GetFiles())
          
{  
              FileStream fs 
= File.OpenRead(item.FullName);   
              
byte[] buffer = new byte[fs.Length];   
              fs.Read(buffer,
0,buffer.Length);   
              
string strEntryName=item.FullName.Replace(strBaseDir,"");
              ZipEntry entry 
= new ZipEntry(strEntryName);
              entry.Size 
= fs.Length;
              zos.PutNextEntry(entry);   
              zos.Write(buffer,
0,buffer.Length);   
              fs.Close();   
          }
   
    }
   

  }

}

综合网络上的,自己小小修改了下
直接使用,发现问题请留言告诉我下...

posted @ 2008-03-31 22:15 七步 阅读(51) | 评论 (0)编辑

C#中使用Flash

      按照网上的方法,先添加"Microsoft Multimedia Control 6.0",再添加"Shockwave Flash Object",可是还是出现"未能导入activex 控件"的错误,最后发现原来是没有把"Microsoft Multimedia Control 6.0"拉到FORM中的原因,拉过去一下就好了.
按照以下步骤应该能够成功:
01.VS2005工具箱中“选择项”-> “COM”中选择“Microsoft Multimedia Control 6.0”,添加.
     【如果没有“Microsoft Multimedia Control 6.0”,则需要注册“ MCI32.OCX”,如果没有就要下载“ MCI32.OCX”地址网上可以搜索到,提供一个地址:MCI32.OCX
     注册方法:
      运行 regsvr32 C:\WINDOWS\system32\MCI32.OCX

02.VS2005工具箱中“选择项”-> “COM”中选择“Shockwave Flash Object” 添加

03.将“Microsoft Multimedia Control 6.0”拖到form中一下(之后可以删除),再拖动“Shockwave Flash Object”进来就可以正常使用了,否则会出现错误。
好了,可以正常使用“Shockwave Flash Object”做FLASH播放器什么的了...

posted @ 2008-03-31 22:12 七步 阅读(40) | 评论 (0)编辑