• 生成TAR或者生成TAR.gz


    using ICSharpCode.SharpZipLib;
    using ICSharpCode.SharpZipLib.Tar;

    public static void Create_Tar_Archive(string IN,string OUT)
    {
    //IN and OUT are directories
    if (IN=="" || OUT=="" || !System.IO.Directory.Exists(IN)
    || !System.IO.Directory.Exists(OUT)) return;
    string OutName=OUT+"\\"+System.IO.Path.GetFileName(IN)+". tar";

    Stream stmout=new FileStream(OutName,FileMode.OpenOrCreate);
    TarArchive
    TA=ICSharpCode.SharpZipLib.Tar.TarArchive.CreateOu tputTarArchive(stmout);
    TarEntry TE=TarEntry.CreateEntryFromFile(IN);
    TA.WriteEntry(TE,true);
    TA.CloseArchive();
    stmout.Close();
    }

     public void CompressTarFile(string fileName)
            {

        fileName="f:\\teat.tar.gz";
                string _fileName = fileName;//压缩后的文件名
                Stream outStream;
                outStream = File.OpenWrite(_fileName);
                outStream = new GZipOutputStream(outStream);
                TarArchive archive = TarArchive.CreateOutputTarArchive(outStream, TarBuffer.DefaultBlockFactor);
                String[] files = Directory.GetFiles("F:");
                foreach (String name in files)
                {
                    TarEntry entry = TarEntry.CreateEntryFromFile(name);
                    archive.WriteEntry(entry, true);
                }
                if (archive != null)
                {
                    archive.CloseArchive();
                }
            }

    /Files/lbg280/生成压缩动态库.rar

     

  • 相关阅读:
    Eclipse workspace被锁定
    OpenWrt增加软件包
    多核cpu关闭、开启核心
    python基础-元组(tuple)及内置方法
    JS变量+作用域
    JS宣传页项目-综合实战
    JS实现轮播图特效(带二级导航)
    JS DOM属性+JS事件
    JS DOM操作(创建、遍历、获取、操作、删除节点)
    JS中BOM操作知识点
  • 原文地址:https://www.cnblogs.com/lbg280/p/1686104.html
Copyright © 2020-2023  润新知