不错的开源压缩组件(可惜没能用上)

不错的开源压缩组件(可惜没能用上),第1张

概述今天继续在研究Silverlight的发布优化方法,由于项目需要开启OOB,没有办法再选中  这两个选项只能选择其中一个,很遗憾不能利用自身的功能合并项目了,这里说明一下,第一个选项的好处 如果你的解决方案中有两个Silverlight项目,那么如果选择了第一项,则两个项目中共同的DLL会被压缩放在ClientBin目录下,这样做的好处是避免了两个SL项目中引用重复的DLL,但是选择OOB之后,我

今天继续在研究Silverlight的发布优化方法,由于项目需要开启OOB,没有办法再选中 

这两个选项只能选择其中一个,很遗憾不能利用自身的功能合并项目了,这里说明一下,第一个选项的好处

如果你的解决方案中有两个Silverlight项目,那么如果选择了第一项,则两个项目中共同的DLL会被压缩放在ClIEntBin目录下,这样做的好处是避免了两个SL项目中引用重复的DLL,但是选择OOB之后,我们便不能选择这个项了,于是我想到在OOB的基础上,将打包好的XAP改成压缩文件,再解压,将两个项目中的公共DLL抽取出来放到ClIEntBin下,当然这样做还涉及到Xap包中的一个文件 

代码 < Deployment  xmlns ="<a href=" http://schemas.microsoft.com/clIEnt/2007/deployment"" > http://schemas.microsoft.com/clIEnt/2007/deployment" </ a >  

xmlns:x="
< href ="http://schemas.microsoft.com/winfx/2006/xaml" " > http://schemas.microsoft.com/winfx/2006/xaml" </ a >  EntryPointAssembly="ProjectA" 

EntryPointType="ProjectA.App" RuntimeVersion="4.0.50401.0"> 
  
< Deployment.OutOfbrowserSettings >  
    
< OutOfbrowserSettings  Shortname ="ProjectA Application"  EnableGPUacceleration ="False"  

ShowInstallMenuItem
="True" >  
      
< OutOfbrowserSettings.Blurb > ProjectA Application on your desktop; at home, at work or on the 

go.
</ OutOfbrowserSettings.Blurb >  
      
< OutOfbrowserSettings.windowsettings >  
        
< windowsettings  Title ="ProjectA Application"   />  
      
</ OutOfbrowserSettings.windowsettings >  
      
< OutOfbrowserSettings.Icons  />  
    
</ OutOfbrowserSettings >  
  
</ Deployment.OutOfbrowserSettings >  
  
< Deployment.Parts >  
    
< AssemblyPart  x:name ="ProjectA"  Source ="ProjectA.dll"   />  
    
< AssemblyPart  x:name ="ProjectB"  Source ="ProjectB.dll"   />  
    
< AssemblyPart  x:name ="System.windows.Controls"  Source ="System.windows.Controls.dll"   />  
    
< AssemblyPart  x:name ="Telerik.windows.Controls"  Source ="Telerik.windows.Controls.dll"   />  
  
</ Deployment.Parts >  
</ Deployment >

 我想将最后两个DLL抽取出来或者改变一下配置路径,但两种方法都没有用,有了解的朋友还请指点。

在解决问题的过程中我下载了一个挺不错的压缩组件

SharpZiplib 有兴趣的朋友可以试试

http://www.icsharpcode.net/OpenSource/SharpZipLib/

简单写了一个类实现压缩和解压缩功能。

代码 using  System; 
using  System.Collections.Generic; 
using  System.linq; 
using  System.Web;

using  System.IO; 
using  ICSharpCode.SharpZiplib.Zip;

namespace  SLProjectsDownLoad.Web 

    
public   class  Zip 
    { 
        
public   static   voID  Zipfiles( string  Zipfilename,  string  FromDirectory) 
        { 
            FastZip fz 
=   new  FastZip(); 
            fz.CreateEmptyDirectorIEs 
=   true
            fz.CreateZip(Zipfilename, FromDirectory, 
true "" ); 
            fz 
=   null
        }

        
public   static   voID  UnZipfiles( string  Zipfilename,  string  ToDirectory) 
        { 
            
if  ( ! Directory.Exists(ToDirectory)) 
                Directory.CreateDirectory(ToDirectory);

            ZipinputStream s 
=   new  ZipinputStream(file.OpenRead(Zipfilename));

            ZipEntry theEntry; 
            
while  ((theEntry  =  s.GetNextEntry())  !=   null
            { 
                
string  directoryname  =  Path.GetDirectoryname(theEntry.name); 
                
string  filename  =  Path.Getfilename(theEntry.name);

                
if  (directoryname  !=  String.Empty) 
                    Directory.CreateDirectory(ToDirectory 
+  directoryname);

                
if  (filename  !=  String.Empty) 
                { 
                    fileStream streamWriter 
=  file.Create(ToDirectory  +  theEntry.name);

                    
int  size  =   2048
                    
byte [] data  =   new   byte [ 2048 ]; 
                    
while  ( true
                    { 
                        size 
=  s.Read(data,  0 , data.Length); 
                        
if  (size  >   0
                        { 
                            streamWriter.Write(data, size); 
                        } 
                        
else  
                        { 
                            
break ;                          }                      }                      streamWriter.Close();                  }              }              s.Close();          }      }  } 总结

以上是内存溢出为你收集整理的不错的开源压缩组件(可惜没能用上)全部内容,希望文章能够帮你解决不错的开源压缩组件(可惜没能用上)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1026662.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存