本文整理汇总了C#中SevenZip.SevenZipCompressor类的典型用法代码示例。如果您正苦于以下问题:C# SevenZipCompressor类的具体用法?C# SevenZipCompressor怎么用?C# SevenZipCompressor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SevenZipCompressor类属于SevenZip命名空间,在下文中一共展示了SevenZipCompressor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Compress
public void Compress(string sourceFilename, string targetFilename, FileMode fileMode, OutArchiveFormat archiveFormat,
CompressionMethod compressionMethod, CompressionLevel compressionLevel, ZipEncryptionMethod zipEncryptionMethod,
string password, int bufferSize, int preallocationPercent, bool check, Dictionary<string, string> customParameters)
{
bufferSize *= this._sectorSize;
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.FastCompression = true;
compressor.ArchiveFormat = archiveFormat;
compressor.CompressionMethod = compressionMethod;
compressor.CompressionLevel = compressionLevel;
compressor.DefaultItemName = Path.GetFileName(sourceFilename);
compressor.DirectoryStructure = false;
compressor.ZipEncryptionMethod = zipEncryptionMethod;
foreach (var pair in customParameters)
{
compressor.CustomParameters[pair.Key] = pair.Value;
}
using (FileStream sourceFileStream = new FileStream(sourceFilename,
FileMode.Open, FileAccess.Read, FileShare.None, bufferSize,
Win32.FileFlagNoBuffering | FileOptions.SequentialScan))
{
using (FileStream targetFileStream = new FileStream(targetFilename,
fileMode, FileAccess.ReadWrite, FileShare.ReadWrite, 8,
FileOptions.WriteThrough | Win32.FileFlagNoBuffering))
{
this.Compress(compressor, sourceFileStream, targetFileStream,
password, preallocationPercent, check, bufferSize);
}
}
}
开发者ID:simony,项目名称:WinUtils,代码行数:30,代码来源:LocalArch.cs
示例2: Zipp
public bool Zipp(IEnumerable<string> iText, string iFileName, string iPassword)
{
CheckArguments(iText, iFileName);
SevenZipCompressor sevenZipCompressor = new SevenZipCompressor()
{
DirectoryStructure = true,
EncryptHeaders = true,
DefaultItemName = "Default.txt"
};
try
{
using (var instream = new MemoryStream())
{
using (var streamwriter = new StreamWriter(instream) { AutoFlush = true })
{
iText.Apply(t => streamwriter.WriteLine(t));
instream.Position = 0;
using (Stream outstream = File.Create(iFileName))
{
sevenZipCompressor.CompressStream(instream, outstream, iPassword);
}
}
}
}
catch (Exception e)
{
Trace.WriteLine(string.Format("Problem zipping a text: {0}", e));
return false;
}
return true;
}
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:34,代码来源:SevenZipZipper.cs
示例3: b_Compress_Click
private void b_Compress_Click(object sender, EventArgs e)
{
SevenZipCompressor.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");
SevenZipCompressor cmp = new SevenZipCompressor();
cmp.Compressing += new EventHandler<ProgressEventArgs>(cmp_Compressing);
cmp.FileCompressionStarted += new EventHandler<FileNameEventArgs>(cmp_FileCompressionStarted);
cmp.CompressionFinished += new EventHandler<EventArgs>(cmp_CompressionFinished);
cmp.ArchiveFormat = (OutArchiveFormat)Enum.Parse(typeof(OutArchiveFormat), cb_Format.Text);
cmp.CompressionLevel = (CompressionLevel)trb_Level.Value;
cmp.CompressionMethod = (CompressionMethod)cb_Method.SelectedIndex;
cmp.VolumeSize = chb_Volumes.Checked ? (int)nup_VolumeSize.Value : 0;
string directory = tb_CompressDirectory.Text;
string archFileName = tb_CompressOutput.Text;
bool sfxMode = chb_Sfx.Checked;
if (!sfxMode)
{
cmp.BeginCompressDirectory(directory, archFileName);
}
else
{
// Build SevenZipSharp with SFX
/*SevenZipSfx sfx = new SevenZipSfx();
using (MemoryStream ms = new MemoryStream())
{
cmp.CompressDirectory(directory, ms);
sfx.MakeSfx(ms, archFileName.Substring(0, archFileName.LastIndexOf('.')) + ".exe");
}*/
}
}
开发者ID:KOLANICH,项目名称:SevenZipSharp,代码行数:29,代码来源:FormMain.cs
示例4: 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
示例5: CreateWrappedArchive
public static byte[] CreateWrappedArchive(string basePath, string[] includes, string[] excludes)
{
using (MemoryStream inStream = new MemoryStream()) {
var zipOut = new SevenZipCompressor();
zipOut.ArchiveFormat = OutArchiveFormat.Zip;
zipOut.CompressionLevel = SevenZip.CompressionLevel.None;
List<string> FileList = new List<string>(Search.FindFiles(
basePath, includes, excludes, SearchOption.AllDirectories
));
SevenZipBase.SetLibraryPath(Inits.EnsureBinaries());
zipOut.CompressFileDictionary(
FileList.ToDictionary(f => f.Replace(basePath, null), f => f),
inStream
);
inStream.Position = 0;
using (var outStream = new MemoryStream()) {
using (var LzmaStream = new LzmaEncodeStream(outStream)) {
int byt = 0;
while ((byt = inStream.ReadByte()) != -1)
LzmaStream.WriteByte((byte)byt);
}
return outStream.ToArray();
}
}
}
开发者ID:IsaacSanch,项目名称:KoruptLib,代码行数:29,代码来源:Lzma.cs
示例6: CompressDirectory
public static void CompressDirectory(string compressDirectory, string archFileName, OutArchiveFormat archiveFormat, CompressionLevel compressionLevel)
{
SevenZipCompressor.SetLibraryPath(LibraryPath);
SevenZipCompressor cmp = new SevenZipCompressor();
cmp.ArchiveFormat = archiveFormat;
cmp.CompressionLevel = compressionLevel;
cmp.BeginCompressDirectory(compressDirectory, archFileName);
}
开发者ID:skt90u,项目名称:skt90u-framework-dotnet,代码行数:8,代码来源:SevenZipLib.cs
示例7: GZipFiles
/// <summary>
/// Compresses files using gzip format
/// </summary>
/// <param name="files">The files.</param>
/// <param name="destination">The destination.</param>
public static void GZipFiles(string[] files, string destination)
{
SetupZlib();
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.ArchiveFormat = OutArchiveFormat.GZip;
compressor.CompressFiles(destination, files);
}
开发者ID:UhuruSoftware,项目名称:vcap-dotnet,代码行数:13,代码来源:ZipUtilities.cs
示例8: 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
示例9: ZipFiles
public static void ZipFiles(string archivePath, params string[] targetFilesPath)
{
var compressor = new SevenZipCompressor();
compressor.ArchiveFormat = OutArchiveFormat.SevenZip;
compressor.CompressionMode = CompressionMode.Create;
compressor.TempFolderPath = System.IO.Path.GetTempPath();
//compressor.CompressDirectory(source, output);
compressor.CompressFiles(archivePath, targetFilesPath);
}
开发者ID:MichalGrzegorzak,项目名称:Ylvis,代码行数:9,代码来源:SevenZipSharp.cs
示例10: 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
示例11: SerializationDemo
public void SerializationDemo(){
ArgumentException ex = new ArgumentException("blahblah");
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
using (MemoryStream ms = new MemoryStream()) {
bf.Serialize(ms, ex);
SevenZipCompressor cmpr = new SevenZipCompressor();
cmpr.CompressStream(ms, File.Create(createTempFileName()));
}
}
开发者ID:KOLANICH,项目名称:SevenZipSharp,代码行数:10,代码来源:SevenZipTestPack.cs
示例12: compress
static public void compress(string source, string outputFileName) {
if (source != null && outputFileName != null) {
SevenZipCompressor.SetLibraryPath("7z.dll");
SevenZipCompressor cmp = new SevenZipCompressor();
cmp.Compressing += new EventHandler<ProgressEventArgs>(cmp_Compressing);
cmp.FileCompressionStarted += new EventHandler<FileNameEventArgs>(cmp_FileCompressionStarted);
cmp.CompressionFinished += new EventHandler<EventArgs>(cmp_CompressionFinished);
cmp.ArchiveFormat = (OutArchiveFormat)Enum.Parse(typeof(OutArchiveFormat), "SevenZip");
cmp.CompressFiles(outputFileName, source);
}
}
开发者ID:AdenFlorian,项目名称:SlickUpdater,代码行数:11,代码来源:Zippy.cs
示例13: Compress
private void Compress(string directory, string archFileName)
{
SevenZipCompressor.SetLibraryPath(AppDomain.CurrentDomain.BaseDirectory + "7z.dll");
SevenZipCompressor cmp = new SevenZipCompressor();
cmp.Compressing += new EventHandler<ProgressEventArgs>(cmp_Compressing);
cmp.FileCompressionStarted += new EventHandler<FileNameEventArgs>(cmp_FileCompressionStarted);
cmp.CompressionFinished += new EventHandler<EventArgs>(cmp_CompressionFinished);
cmp.ArchiveFormat = OutArchiveFormat.SevenZip;
cmp.CompressionLevel = CompressionLevel.Normal;
cmp.BeginCompressDirectory(directory, archFileName);
}
开发者ID:450640526,项目名称:HtmExplorer,代码行数:11,代码来源:BackupForm.cs
示例14: packToZip
public void packToZip(String filePathArchive, String romFolder)
{
if(!Directory.Exists(tempPath)){
Directory.CreateDirectory(tempPath);
}
archivePacker = new SevenZipCompressor(tempFolder);
archivePacker.ArchiveFormat = OutArchiveFormat.Zip;
archivePacker.BeginCompressDirectory(romFolder, filePathArchive, "");
}
开发者ID:rockdesignes,项目名称:ROMCollectionManager,代码行数:11,代码来源:RomBackupArchiveManager.cs
示例15: 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
示例16: b_Compress_Click
private void b_Compress_Click(object sender, RoutedEventArgs e)
{
SevenZipCompressor.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");
SevenZipCompressor cmp = new SevenZipCompressor();
cmp.Compressing += new EventHandler<ProgressEventArgs>(cmp_Compressing);
cmp.FileCompressionStarted += new EventHandler<FileNameEventArgs>(cmp_FileCompressionStarted);
cmp.CompressionFinished += new EventHandler<EventArgs>(cmp_CompressionFinished);
cmp.ArchiveFormat = (OutArchiveFormat)Enum.Parse(typeof(OutArchiveFormat), cb_Format.Text);
cmp.CompressionLevel = (CompressionLevel)slider_Level.Value;
string directory = tb_CompressFolder.Text;
string archFileName = tb_CompressArchive.Text;
cmp.BeginCompressDirectory(directory, archFileName);
}
开发者ID:Ethan6Lu,项目名称:SevenZipSharp,代码行数:13,代码来源:MainWindow.xaml.cs
示例17: SevenZIP
public static void SevenZIP(List<string> files, string output)
{
SevenZipExtractor.SetLibraryPath(ConfigurationManager.AppSettings["7ZIPDLL"]);
SevenZipCompressor.SetLibraryPath(ConfigurationManager.AppSettings["7ZIPDLL"]);
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.ArchiveFormat = OutArchiveFormat.SevenZip;
compressor.CompressionMode = CompressionMode.Create;
compressor.TempFolderPath = System.IO.Path.GetTempPath();
//compressor.VolumeSize = 51200000;//50 MB
compressor.CompressFiles(output, files.ToArray());
}
开发者ID:mberaz,项目名称:ex10ntions,代码行数:13,代码来源:seven+zip+Compresor.cs
示例18: ExecuteCore
protected override void ExecuteCore()
{
SevenZipCompressor compressor = null;
try
{
var files = this.GetAllSources().ToList();
foreach (var file in files) FileHelper.WaitForReady(FileHelper.GetDataFilePath(file));
long nextLength = 0, nextFile = 0;
FileLength = files.Sum(file => new FileInfo(FileHelper.GetFilePath(file)).Length);
compressor = new SevenZipCompressor
{
CompressionLevel = (CompressionLevel)Enum.Parse(typeof(CompressionLevel),
TaskXml.GetAttributeValue("compressionLevel"), true)
};
switch (Path.GetExtension(RelativePath).ToLowerInvariant())
{
case ".7z":
compressor.ArchiveFormat = OutArchiveFormat.SevenZip;
break;
case ".zip":
compressor.ArchiveFormat = OutArchiveFormat.Zip;
break;
case ".tar":
compressor.ArchiveFormat = OutArchiveFormat.Tar;
break;
}
var filesStart = Path.GetFullPath(FileHelper.GetFilePath(string.Empty)).Length + 1;
compressor.FileCompressionStarted += (sender, e) =>
{
ProcessedSourceCount += nextFile;
ProcessedFileLength += nextLength;
nextFile = 1;
nextLength = new FileInfo(e.FileName).Length;
CurrentSource = e.FileName.Substring(filesStart);
Save();
};
compressor.CompressFiles(FileHelper.GetFilePath(RelativePath),
Path.GetFullPath(FileHelper.GetFilePath(BaseFolder)).Length + 1,
files.Select(file => Path.GetFullPath(FileHelper.GetFilePath(file))).ToArray());
ProcessedSourceCount += nextFile;
ProcessedFileLength += nextLength;
Finish();
}
catch (SevenZipException)
{
if (compressor == null) throw;
throw new AggregateException(compressor.Exceptions);
}
}
开发者ID:GuardSources,项目名称:Skylark,代码行数:49,代码来源:Program.cs
示例19: 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
示例20: CreateCacheFile
/// <summary>
/// Creates a cache file for the given mod, containing the specified files.
/// </summary>
/// <param name="p_modMod">The mod for which to create the cache file.</param>
/// <param name="p_strFilesToCacheFolder">The folder containing the files to put into the cache.</param>
/// <returns>The cache file for the specified mod, or <c>null</c>
/// if there were no files to cache.</returns>
public Archive CreateCacheFile(IMod p_modMod, string p_strFilesToCacheFolder)
{
if (!String.IsNullOrEmpty(p_strFilesToCacheFolder))
{
string[] strFilesToCompress = Directory.GetFiles(p_strFilesToCacheFolder, "*.*", SearchOption.AllDirectories);
if (strFilesToCompress.Length > 0)
{
string strCachePath = GetCacheFilePath(p_modMod);
SevenZipCompressor szcCompressor = new SevenZipCompressor();
szcCompressor.ArchiveFormat = OutArchiveFormat.Zip;
szcCompressor.CompressionLevel = CompressionLevel.Ultra;
szcCompressor.CompressDirectory(p_strFilesToCacheFolder, strCachePath);
return new Archive(strCachePath);
}
}
return null;
}
开发者ID:ThosRTanner,项目名称:modorganizer-NCC,代码行数:24,代码来源:NexusModCacheManager.cs
注:本文中的SevenZip.SevenZipCompressor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论