zoukankan      html  css  js  c++  java
  • 生成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

     

  • 相关阅读:
    ZOJ3513_Human or Pig
    ZOJ2083_Win the Game
    ZOJ2725_Digital Deletions
    ZOJ2686_Cycle Gameu
    UVALive
    ZOJ2290_Game
    ZOJ3067_Nim
    P3159 [CQOI2012]交换棋子(费用流)
    P3153 [CQOI2009]跳舞(最大流多重匹配)
    P3121 [USACO15FEB]审查(黄金)Censoring (Gold)(ac自动机)
  • 原文地址:https://www.cnblogs.com/lbg280/p/1686104.html
Copyright © 2011-2022 走看看