当前位置: 首页>>代码示例>>C#>>正文


C# SevenZipCompressor.CompressDirectory方法代码示例

本文整理汇总了C#中SevenZip.SevenZipCompressor.CompressDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# SevenZipCompressor.CompressDirectory方法的具体用法?C# SevenZipCompressor.CompressDirectory怎么用?C# SevenZipCompressor.CompressDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SevenZip.SevenZipCompressor的用法示例。


在下文中一共展示了SevenZipCompressor.CompressDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompressionTestsVerySimple

		public void CompressionTestsVerySimple(){
			var tmp = new SevenZipCompressor();
			//tmp.ScanOnlyWritable = true;
			//tmp.CompressFiles(@"d:\Temp\arch.7z", @"d:\Temp\log.txt");
			//tmp.CompressDirectory(@"c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\1033", @"D:\Temp\arch.7z");
			tmp.CompressDirectory(testFold1, Path.Combine(tempFolder, TestContext.TestName + ".7z"));
		}
开发者ID:KOLANICH,项目名称:SevenZipSharp,代码行数:7,代码来源:SevenZipTestPack.cs

示例2: ZipFolder

 public static void ZipFolder(string archivePath, string targetDir)
 {
     var compressor = new SevenZipCompressor();
     compressor.ArchiveFormat = OutArchiveFormat.SevenZip;
     compressor.CompressionMode = CompressionMode.Create;
     compressor.TempFolderPath = System.IO.Path.GetTempPath();
     compressor.CompressDirectory(targetDir, archivePath);
 }
开发者ID:MichalGrzegorzak,项目名称:Ylvis,代码行数:8,代码来源:SevenZipSharp.cs

示例3: Pack

 public void Pack(string outputPath)
 {
     SevenZipCompressor tmp = new SevenZipCompressor();
     tmp.FileCompressionStarted += new EventHandler<FileInfoEventArgs>((s, e) => 
     {
         Console.WriteLine(String.Format("[{0}%] {1}",
             e.PercentDone, e.FileInfo.Name));
     });
     tmp.CompressDirectory(_targetPath, outputPath, OutArchiveFormat.SevenZip);
 }
开发者ID:MichalGrzegorzak,项目名称:Ylvis,代码行数:10,代码来源:ZipHelper.cs

示例4: Compress

        private static void Compress(string savePath, string backupPath, CompressionLevel compressionLevel = CompressionLevel.None)
        {
            SevenZipCompressor compressor = new SevenZipCompressor();
            compressor.CustomParameters.Add("mt", "on");
            compressor.CompressionLevel = compressionLevel;
            compressor.ScanOnlyWritable = true;

            if (!Directory.Exists(backupPath))
                Directory.CreateDirectory(backupPath);

            compressor.CompressDirectory(savePath, (Path.Combine(backupPath, GetTimeStamp()) + ".7z"));
        }
开发者ID:FreeReign,项目名称:forkuo,代码行数:12,代码来源:Main.cs

示例5: CreatePackage

        public string CreatePackage()
        {
            // Create the package file
            if (File.Exists(InstallPerpParms.FileLocation.ToString() + "\\profile.cfg") == true)
            {
                File.Delete(InstallPerpParms.FileLocation.ToString() + "\\profile.cfg");
            }

            File.Create(InstallPerpParms.FileLocation.ToString() + "\\profile.cfg").Close();

            using( StreamWriter ProfileStream = new StreamWriter(InstallPerpParms.FileLocation.ToString() + "\\profile.cfg"))
            {
                ProfileStream.WriteLine("GameName=" + PackageFile.GameName);
                ProfileStream.WriteLine("GameDir=" + PackageFile.GameDir.ToString());
                ProfileStream.WriteLine("CurrentVersion=" + PackageFile.VersionNumber);
                ProfileStream.WriteLine("UpdateURL=" + PackageFile.UpdateURL.ToString());
                ProfileStream.WriteLine("DescriptionURL=" + PackageFile.DescURL.ToString());
                ProfileStream.WriteLine("GameType=" + PackageFile.TypeGame.ToString());
                ProfileStream.WriteLine("LoginType=" + PackageFile.TypeLogin.ToString());
                ProfileStream.WriteLine("CommandLineArgs=" + PackageFile.CommandLine);

                ProfileStream.Flush();
                ProfileStream.Close();
            }

            // create installer
            SevenZipSfx Installer = new SevenZipSfx();
            SevenZipCompressor Compress = new SevenZipCompressor("C:\\Temp\\Compress");

            // installer settings
            Dictionary<string, string> Settings = new Dictionary<string, string>
                    {
                        { "Title", PackageFile.GameName + " " + PackageFile.VersionNumber },
                        { "InstallPath", PackageFile.GameDir },
                        { "BeginPrompt", "Yükleme işlemi başlatılsın mı?" },
                        { "CancelPrompt", "Yükleme işlemi iptal edilecek?" },
                        { "OverwriteMode", "2" },
                        { "GUIMode", "1" },
                        { "ExtractDialogText", "Dosyalar ayıklanıyor" },
                        { "ExtractTitle", "Ayıklama İşlemi" },
                        { "ErrorTitle", "Hata!" }
                    };

             Compress.CompressDirectory(InstallPerpParms.FileLocation.ToString(), "c:\\temp\\compress.7zip");
             Installer.ModuleFileName = Directory.GetCurrentDirectory() + "\\7zxSD_LZMA.sfx";
             Installer.MakeSfx("c:\\temp\\compress.7zip", Settings, Directory.GetCurrentDirectory() + "\\" + InstallPerpParms.FileName);

            return "Done";
        }
开发者ID:DungeonsAndShotguns,项目名称:DS-Launcher,代码行数:49,代码来源:CratePackage.cs

示例6: Open

 public override void Open()
 {
     string source_folder = @"D:\test";
         //путь к папке, которую нужно поместить в архив
     string archive_name = "qwerty.zip"; //имя архива
     string library_source = "SevenZipSharp.dll"; //Путь к файлу 7zip.dll
     if (File.Exists(library_source)) //Если библиотека 7zip существует
     {
         SevenZipBase.SetLibraryPath(library_source); //Подгружаем библиотеку 7zip
         var compressor = new SevenZipCompressor(); //Объявляем переменную архиватора
         compressor.ArchiveFormat = OutArchiveFormat.SevenZip; //Выбираем формат архива
         compressor.CompressionLevel = CompressionLevel.Ultra; // ультра режим сжатия
         compressor.CompressionMode = CompressionMode.Create; //подтверждаются настройки
         compressor.TempFolderPath = System.IO.Path.GetTempPath();//объявляется временная папка
         compressor.CompressDirectory(source_folder, archive_name, false); //сам процесс сжатия
     }
 }
开发者ID:gitter-badger,项目名称:File-1,代码行数:17,代码来源:ArchiveFile.cs

示例7: execute

        public void execute(MinecraftPaths p)
        {
            Regex zip = new Regex(@"ZIP$");
            if (zip.IsMatch(target))
            {
                SevenZip.SevenZipCompressor comp = new SevenZipCompressor();
                Match m = zip.Match(target);

                target = target.Remove(m.Index) + "NAME";
                comp.CompressDirectory(p.resolvePath(source, ExtraTags), p.resolvePath(target, ExtraTags));

            }
            else
            {
                SMMMUtil.FileSystemUtils.CopyDirectory(p.resolvePath(source, ExtraTags), p.resolvePath(target, ExtraTags));

            }
        }
开发者ID:barcharcraz,项目名称:SMMM,代码行数:18,代码来源:DirectoryCopyAction.cs

示例8: Compress

		/// <summary>
		/// Compresses the specified source folder into a mod file at the specified destination.
		/// </summary>
		/// <remarks>
		/// If the desitnation file exists, it will be overwritten.
		/// </remarks>
		/// <param name="p_strSourcePath">The folder to compress into a mod file.</param>
		/// <param name="p_strDestinationPath">The path of the mod file to create.</param>
		public override void Compress(string p_strSourcePath, string p_strDestinationPath)
		{
			Int32 intFileCount = Directory.GetFiles(p_strSourcePath).Length;
			SevenZipCompressor szcCompressor = new SevenZipCompressor();
			szcCompressor.CompressionLevel = EnvironmentInfo.Settings.ModCompressionLevel;
			szcCompressor.ArchiveFormat = EnvironmentInfo.Settings.ModCompressionFormat;
			szcCompressor.CompressionMethod = CompressionMethod.Default;
			switch (szcCompressor.ArchiveFormat)
			{
				case OutArchiveFormat.Zip:
				case OutArchiveFormat.GZip:
				case OutArchiveFormat.BZip2:
					szcCompressor.CustomParameters.Add("mt", "on");
					break;
				case OutArchiveFormat.SevenZip:
				case OutArchiveFormat.XZ:
					szcCompressor.CustomParameters.Add("mt", "on");
					szcCompressor.CustomParameters.Add("s", "off");
					break;
			}
			szcCompressor.CompressionMode = CompressionMode.Create;
			szcCompressor.FileCompressionStarted += new EventHandler<FileNameEventArgs>(Compressor_FileCompressionStarted);
			szcCompressor.CompressDirectory(p_strSourcePath, p_strDestinationPath);
		}
开发者ID:NexusMods,项目名称:NexusModManager-4.5,代码行数:32,代码来源:FOModModCompressor.cs

示例9: compressDirectory

 /// <param name="zip">Compressor.</param>
 /// <param name="path">Input directory.</param>
 /// <param name="name">Archive name.</param>
 protected virtual void compressDirectory(SevenZipCompressor zip, string path, string name)
 {
     zip.CompressDirectory(path, name);
 }
开发者ID:3F,项目名称:vsCommandEvent,代码行数:7,代码来源:SevenZipComponent.cs

示例10: Compress

 public static void Compress(string directory, string file)
 {
     var compressor = new SevenZipCompressor();
     compressor.CompressDirectory(directory, file);
 }
开发者ID:shirshmx,项目名称:Monocle-Record-Rssdk,代码行数:5,代码来源:Lzma.cs

示例11: Pack

        public void Pack(string sourcePath, string destinationPath)
        {
            var skin = Path.Combine(sourcePath, "Skin.xml");
            var cursorsDir = Path.Combine(sourcePath, "Cursors");
            var fontsDir = Path.Combine(sourcePath, "Fonts");
            var imagesDir = Path.Combine(sourcePath, "Images");

            if (!File.Exists(skin) || !Directory.Exists(cursorsDir) || !Directory.Exists(fontsDir) || !Directory.Exists(imagesDir))
            {
                logger.Error("Cursors, Fonts, Images and Skin.xml are required");
                return;
            }

            logger.Info("Packing skin '{0}'", sourcePath);

            var tempDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "Gnomoria.ContentExtractor", Guid.NewGuid().ToString())).FullName;
            var skinRoot = Path.Combine(tempDir, "skinRoot");
            Directory.CreateDirectory(skinRoot);

            logger.Debug("Packing Skin.xml");
            using (var file = File.Create(Path.Combine(skinRoot, "Skin.xnb")))
            using (var xml = File.OpenRead(skin))
            {
                var header = SkinHeader.Split(' ')
                                       .Select(s => Convert.ToByte(s, 16))
                                       .ToArray();
                file.Write(header, 0, header.Length);
                xml.CopyTo(file);
            }

            logger.Debug("Packing images");
            var images = Directory.GetFiles(imagesDir, "*.png", SearchOption.AllDirectories);
            var destination = Path.Combine(skinRoot, "Images");
            PackSkinImages(images, imagesDir, destination, tempDir);

            logger.Debug("Copying fonts");
            // since fonts arent unpacked by this tool, just copy the XNBs
            destination = Path.Combine(skinRoot, "Fonts");
            var fonts = Directory.GetFiles(fontsDir, "*.xnb", SearchOption.AllDirectories);
            Directory.CreateDirectory(destination);

            foreach (var font in fonts)
            {
                var name = Path.GetFileNameWithoutExtension(font);

                File.Copy(font, Path.Combine(destination, name + ".xnb"), true);
            }

            logger.Debug("Copying cursors");
            // since fonts arent unpacked by this tool, just copy the XNBs
            destination = Path.Combine(skinRoot, "Cursors");
            var cursors = Directory.GetFiles(cursorsDir, "*.xnb", SearchOption.AllDirectories);
            Directory.CreateDirectory(destination);

            foreach (var cursor in cursors)
            {
                var name = Path.GetFileNameWithoutExtension(cursor);

                File.Copy(cursor, Path.Combine(destination, name + ".xnb"), true);
            }

            logger.Debug("Zipping skin contents");
            var zipper = new SevenZipCompressor
            {
                PreserveDirectoryRoot = false,
                ArchiveFormat = OutArchiveFormat.Zip,
                CompressionLevel = CompressionLevel.Ultra,
            };

            zipper.CompressDirectory(skinRoot, destinationPath, true);

            logger.Debug("Cleaning up temp files");
            Directory.Delete(tempDir, true);
        }
开发者ID:Rfvgyhn,项目名称:Gnomoria.ContentExtractor,代码行数:74,代码来源:SkinManager.cs

示例12: fomod

        /// <summary>
        /// A simple constructor that initializes the object.
        /// </summary>
        /// <param name="path">The path to the fomod file.</param>
        internal fomod(string path, bool p_booUseCache)
        {
            this.filepath = path;
            ModName = System.IO.Path.GetFileNameWithoutExtension(path);

            m_arcFile = new Archive(path);
            m_strCachePath = Path.Combine(Program.GameMode.ModInfoCacheDirectory, ModName + ".zip");
            if (p_booUseCache && File.Exists(m_strCachePath))
                m_arcCacheFile = new Archive(m_strCachePath);

            FindPathPrefix();
            m_arcFile.FilesChanged += new EventHandler(Archive_FilesChanged);
            baseName = ModName.ToLowerInvariant();
            Author = DEFAULT_AUTHOR;
            Description = Email = Website = string.Empty;
            HumanReadableVersion = DEFAULT_VERSION;
            MachineVersion = DefaultVersion;
            MinFommVersion = DefaultMinFommVersion;
            Groups = new string[0];
            isActive = (InstallLog.Current.GetModKey(this.baseName) != null);

            //check for script
            for (int i = 0; i < FomodScript.ScriptNames.Length; i++)
                if (ContainsFile("fomod/" + FomodScript.ScriptNames[i]))
                {
                    m_strScriptPath = "fomod/" + FomodScript.ScriptNames[i];
                    break;
                }

            //check for readme
            for (int i = 0; i < Readme.ValidExtensions.Length; i++)
                if (ContainsFile("readme - " + baseName + Readme.ValidExtensions[i]))
                {
                    m_strReadmePath = "Readme - " + Path.GetFileNameWithoutExtension(path) + Readme.ValidExtensions[i];
                    break;
                }
            if (String.IsNullOrEmpty(m_strReadmePath))
                for (int i = 0; i < Readme.ValidExtensions.Length; i++)
                    if (ContainsFile("docs/readme - " + baseName + Readme.ValidExtensions[i]))
                    {
                        m_strReadmePath = "docs/Readme - " + Path.GetFileNameWithoutExtension(path) + Readme.ValidExtensions[i];
                        break;
                    }

            //check for screenshot
            string[] extensions = new string[] { ".png", ".jpg", ".bmp" };
            for (int i = 0; i < extensions.Length; i++)
                if (ContainsFile("fomod/screenshot" + extensions[i]))
                {
                    m_strScreenshotPath = "fomod/screenshot" + extensions[i];
                    break;
                }

            if (p_booUseCache && !File.Exists(m_strCachePath) && (m_arcFile.IsSolid || m_arcFile.ReadOnly))
            {
                string strTmpInfo = Program.CreateTempDirectory();
                try
                {
                    Directory.CreateDirectory(Path.Combine(strTmpInfo, GetPrefixAdjustedPath("fomod")));

                    if (ContainsFile("fomod/info.xml"))
                        File.WriteAllBytes(Path.Combine(strTmpInfo, GetPrefixAdjustedPath("fomod/info.xml")), GetFileContents("fomod/info.xml"));
                    else
                        File.WriteAllText(Path.Combine(strTmpInfo, GetPrefixAdjustedPath("fomod/info.xml")), "<fomod/>");

                    if (!String.IsNullOrEmpty(m_strReadmePath))
                        File.WriteAllBytes(Path.Combine(strTmpInfo, GetPrefixAdjustedPath(m_strReadmePath)), GetFileContents(m_strReadmePath));

                    if (!String.IsNullOrEmpty(m_strScreenshotPath))
                        File.WriteAllBytes(Path.Combine(strTmpInfo, GetPrefixAdjustedPath(m_strScreenshotPath)), GetFileContents(m_strScreenshotPath));

                    string[] strFilesToCompress = Directory.GetFiles(strTmpInfo, "*.*", SearchOption.AllDirectories);
                    if (strFilesToCompress.Length > 0)
                    {
                        SevenZipCompressor szcCompressor = new SevenZipCompressor();
                        szcCompressor.ArchiveFormat = OutArchiveFormat.Zip;
                        szcCompressor.CompressionLevel = CompressionLevel.Ultra;
                        szcCompressor.CompressDirectory(strTmpInfo, m_strCachePath);
                    }
                }
                finally
                {
                    FileUtil.ForceDelete(strTmpInfo);
                }
                if (File.Exists(m_strCachePath))
                    m_arcCacheFile = new Archive(m_strCachePath);
            }

            LoadInfo();
        }
开发者ID:BioBrainX,项目名称:fomm,代码行数:94,代码来源:fomod.cs

示例13: Compress

        private void Compress()
        {
            //setup settings.
            try
            {
                _sevenZipCompressor = new SevenZipCompressor(tempPath);
                _sevenZipCompressor.ArchiveFormat = _format;
                _sevenZipCompressor.CompressionMethod = CompressionMethod.Default;
                _sevenZipCompressor.DirectoryStructure = true;
                _sevenZipCompressor.IncludeEmptyDirectories = true;
                _sevenZipCompressor.FastCompression = _fastcompression;
                _sevenZipCompressor.PreserveDirectoryRoot = false;
                _sevenZipCompressor.CompressionLevel = _compresstionlevel;

                _sevenZipCompressor.Compressing += Compressing;
                _sevenZipCompressor.FileCompressionStarted += FileCompressionStarted;
                _sevenZipCompressor.CompressionFinished += CompressionFinished;
                _sevenZipCompressor.FileCompressionFinished += FileCompressionFinished;

                try
                {
                    if (_password != null)
                    {
                        for (int i = 0; i < _fileAndDirectoryFullPaths.Count; i++)
                        {
                            if (!Directory.Exists(_fileAndDirectoryFullPaths[i]))
                                continue;

                            //Compress directories
                            var strings = _fileAndDirectoryFullPaths[i].Split('/');
                            if (_fileAndDirectoryFullPaths.Count == 1)
                            {
                                _sevenZipCompressor.CompressDirectory(_fileAndDirectoryFullPaths[i],
                                                                      String.Format("{0}/{1}.{2}",
                                                                                    _archivePath,
                                                                                    _archivename,
                                                                                    SelectExtention(_format)));
                            }
                            else
                            {
                                _sevenZipCompressor.CompressDirectory(_fileAndDirectoryFullPaths[i],
                                                                      String.Format("{0}/{1}_{3}.{2}",
                                                                                    _archivePath,
                                                                                    _archivename,
                                                                                    SelectExtention(_format),
                                                                                    _fileAndDirectoryFullPaths[i].Split('\\')
                                                                                            .Last()),
                                                                      _password);
                            }

                            //remove the directorys from the list so they will not be compressed as files as wel
                            _fileAndDirectoryFullPaths.Remove(_fileAndDirectoryFullPaths[i]);
                        }
                        //compress files
                        if (_fileAndDirectoryFullPaths.Count > 0)
                        {
                            _sevenZipCompressor.FileCompressionFinished += FileCompressionFinished;
                            _sevenZipCompressor.CompressFilesEncrypted(
                                                                       String.Format("{0}/{1}.{2}",
                                                                                     _archivePath,
                                                                                     _archivename,
                                                                                     SelectExtention(_format)),
                                                                       _password,
                                                                       _fileAndDirectoryFullPaths.ToArray());
                        }
                    }
                    else
                    {
                        for (int i = 0; i < _fileAndDirectoryFullPaths.Count; i++)
                        //var fullPath in _fileAndDirectoryFullPaths)
                        {
                            FileInfo fi = new FileInfo(_fileAndDirectoryFullPaths[i]);
                            bytesoffiles += fi.Length;

                            if (!Directory.Exists(_fileAndDirectoryFullPaths[i]))
                                continue;

                            //Compress directorys
                            var strings = _fileAndDirectoryFullPaths[i].Split('/');
                            if (_fileAndDirectoryFullPaths.Count == 1)
                            {
                                _sevenZipCompressor.CompressDirectory(_fileAndDirectoryFullPaths[i],
                                                                      String.Format("{0}/{1}.{2}",
                                                                                    _archivePath,
                                                                                    _archivename,
                                                                                    SelectExtention(_format)));
                            }
                            else
                            {
                                _sevenZipCompressor.CompressDirectory(_fileAndDirectoryFullPaths[i],
                                                                      String.Format("{0}/{1}_{3}.{2}",
                                                                                    _archivePath,
                                                                                    _archivename,
                                                                                    SelectExtention(_format),
                                                                                    _fileAndDirectoryFullPaths[i].Split('\\')
                                                                                            .Last()));
                            }

                            //reset compression bar
                            //FileCompressionFinished(null, null);
//.........这里部分代码省略.........
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:101,代码来源:ArchiveProcressScreen.cs

示例14: StreamingCompressionTest

		public void StreamingCompressionTest(){
			var tmp = new SevenZipCompressor();
			tmp.FileCompressionStarted += (s, e) =>{
				//TestContext.WriteLine(String.Format("[{0}%] {1}",e.PercentDone, e.FileName));
			};
			tmp.CompressDirectory(testFold1,
				File.Create(Path.Combine(tempFolder, TestContext.TestName + ".7z")));
		}
开发者ID:KOLANICH,项目名称:SevenZipSharp,代码行数:8,代码来源:SevenZipTestPack.cs

示例15: MultiTaskedCompressionTest

		public async Task MultiTaskedCompressionTest(){
			var t1 = Task.Factory.StartNew(() =>{
				var tmp = new SevenZipCompressor();
				tmp.FileCompressionStarted +=
					(s, e) => TestContext.WriteLine(String.Format("[{0}%] {1}", e.PercentDone, e.FileName));
				tmp.CompressDirectory(testFold1, Path.Combine(tempFolder, TestContext.TestName + "1.7z"));
			});
			var t2 = Task.Factory.StartNew(() =>{
				var tmp = new SevenZipCompressor();
				tmp.FileCompressionStarted +=
					(s, e) => TestContext.WriteLine(String.Format("[{0}%] {1}", e.PercentDone, e.FileName));
				tmp.CompressDirectory(testFold2, Path.Combine(tempFolder, TestContext.TestName + "2.7z"));
			});
			await Task.WhenAll(t1, t2);
		}
开发者ID:KOLANICH,项目名称:SevenZipSharp,代码行数:15,代码来源:SevenZipTestPack.cs


注:本文中的SevenZip.SevenZipCompressor.CompressDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。