本文整理汇总了C#中SevenZip.SevenZipExtractor类的典型用法代码示例。如果您正苦于以下问题:C# SevenZipExtractor类的具体用法?C# SevenZipExtractor怎么用?C# SevenZipExtractor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SevenZipExtractor类属于SevenZip命名空间,在下文中一共展示了SevenZipExtractor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: docxParser
public static String docxParser(String filename)
{
//path to the systems temporary folder
String tempFolderPath = Path.GetTempPath();
//set the path of the 7z.dll (it needs to be in the debug folder)
SevenZipExtractor.SetLibraryPath("7z.dll");
SevenZipExtractor extractor = new SevenZipExtractor(filename);
//create a filestream for the file we are going to extract
FileStream f = new FileStream(tempFolderPath + "document.xml", FileMode.Create);
//extract the document.xml
extractor.ExtractFile("word\\document.xml", f);
//get rid of the object because it is unmanaged
extractor.Dispose();
//close the filestream
f.Close();
//send document.xml that we extracted from the .docx to the xml parser
String result = XMLParser.Parser.ParseXMLtoString(tempFolderPath + "document.xml");
//delete the extracted file from the temp folder
File.Delete(tempFolderPath + "document.xml");
return result;
}
开发者ID:mtotheikle,项目名称:EWU-OIT-SSN-Scanner,代码行数:30,代码来源:MSOfficeParsers.cs
示例2: Execute
public override void Execute()
{
var libraryPath = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), Environment.Is64BitProcess ? "7z64.dll" : "7z.dll");
SevenZipBase.SetLibraryPath(libraryPath);
var targetPath = new FileInfo(Path.Combine(_cmdlet.SessionState.Path.CurrentFileSystemLocation.Path, _cmdlet.TargetPath)).FullName;
var archiveFileName = new FileInfo(Path.Combine(_cmdlet.SessionState.Path.CurrentFileSystemLocation.Path, _cmdlet.ArchiveFileName)).FullName;
var activity = String.Format("Extracting {0} to {1}", System.IO.Path.GetFileName(archiveFileName), targetPath);
var statusDescription = "Extracting";
Write(String.Format("Extracting archive {0}", archiveFileName));
WriteProgress(new ProgressRecord(0, activity, statusDescription) { PercentComplete = 0 });
using (var extractor = new SevenZipExtractor(archiveFileName)) {
extractor.Extracting += (sender, args) =>
WriteProgress(new ProgressRecord(0, activity, statusDescription) { PercentComplete = args.PercentDone });
extractor.FileExtractionStarted += (sender, args) => {
statusDescription = String.Format("Extracting file {0}", args.FileInfo.FileName);
Write(statusDescription);
};
extractor.ExtractArchive(targetPath);
}
WriteProgress(new ProgressRecord(0, activity, "Finished") { RecordType = ProgressRecordType.Completed });
Write("Extraction finished");
}
开发者ID:aolszowka,项目名称:7Zip4Powershell,代码行数:27,代码来源:Expand7Zip.cs
示例3: FileReader
public FileReader(IFileStreamWrap stream)
{
if (stream == null) throw new ArgumentNullException(nameof(stream));
//Asses file ext
var ext = Path.GetExtension(stream.Name);
if (ext == ".gz")
{
Compression = CompressionScheme.GZip;
}
//Assign stream
Stream = stream;
//If not testing assign actual stream
if (stream.FileStreamInstance != null)
{
if (Compression == CompressionScheme.None)
{
_reader = new StreamReaderWrap(stream.FileStreamInstance);
}
else if (Compression == CompressionScheme.GZip)
{
// Toggle between the x86 and x64 bit dll
// var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),Environment.Is64BitProcess ? "x64" : "x86", "7z.dll");
SevenZipExtractor.SetLibraryPath("C:\\Program Files (x86)\\7-Zip\\7z.dll");
_gzipStream = new SevenZipExtractor(stream.FileStreamInstance);
//_memoryStream = new MemoryStream();
//_gzipStream.ExtractFile(0, _memoryStream);
_gzipStream.ExtractArchive("D:\\test.txt");
_reader = new StreamReaderWrap(_memoryStream);
}
}
}
开发者ID:UCL-Genomics,项目名称:genomics-common,代码行数:35,代码来源:FileReader.cs
示例4: Decompress
/// <summary>
/// Decompresses an archive.
/// </summary>
/// <param name="archive">Path for the archive</param>
/// <param name="destination">Archive content destination folder.</param>
/// <returns>True if no errors</returns>
public static bool Decompress(string archive, string destination)
{
try {
string archive_name = Path.GetFileNameWithoutExtension(archive);
if(main.full_path_output)
console.Write("Extracting " + archive + " to " + destination + " -> 0%", console.msgType.standard, false);
else
console.Write("Extracting " + archive_name + " to " + destination + " -> 0%", console.msgType.standard, false);
SevenZipExtractor zip = new SevenZipExtractor(archive);
zip.Extracting += Zip_Extracting;
if (!main.overwrite)
zip.FileExists += Zip_FileExists;
if (main.create_dir)
{
zip.ExtractArchive(destination + @"\" + archive_name);
}
else
zip.ExtractArchive(destination);
Console.WriteLine("");
return true;
}
catch (Exception e)
{
Console.WriteLine("");
console.Write(e.Message +"("+archive+")", console.msgType.error);
Log(e.ToString());
return false;
}
}
开发者ID:Gabisonfire,项目名称:norar,代码行数:36,代码来源:io.cs
示例5: Update
public void Update()
{
if (!IsUpdateAvailable())
{
throw new LauncherException("no update is available");
}
using (var mutex = new WurmAssistantMutex())
{
mutex.Enter(1000, "You must close Wurm Assistant before running update");
var newFileZipped = WebApiClientSpellbook.GetFileFromWebApi(
AppContext.WebApiBasePath,
string.Format("{0}/{1}", AppContext.ProjectName, buildType),
TimeSpan.FromSeconds(15),
BasePath);
using (var extractor = new SevenZipExtractor(newFileZipped.FullName))
{
extractor.ExtractArchive(BasePath);
}
Thread.Sleep(1000);
var cleaner = new DirCleaner(BasePath);
cleaner.Cleanup();
}
}
开发者ID:webba,项目名称:WurmAssistant2,代码行数:27,代码来源:Updater.cs
示例6: ZipContainer
public ZipContainer(SevenZipExtractor zip, ArchiveFileInfo entry, ZipContainer parent)
{
_name = entry.FileName;
_entry = entry;
Zip = zip;
_parent = parent;
}
开发者ID:devshorts,项目名称:FileSystemTraversal,代码行数:7,代码来源:ZipContainer.cs
示例7: Execute
public override void Execute(DirectoryInfo targetDirectory, PortableEnvironment portableEnvironment)
{
// Decompress the file.
SevenZipBase.SetLibraryPath(SevenZipLibPath);
using (var extractor = new SevenZipExtractor(Path.Combine(targetDirectory.FullName, FileName)))
extractor.ExtractArchive(targetDirectory.FullName);
}
开发者ID:wernight,项目名称:papps-manager,代码行数:7,代码来源:ExtractCommand.cs
示例8: RarImporterHelper
internal RarImporterHelper(SevenZipExtractor Sex)
{
string FileName = Sex.FileName;
_DP = Path.GetFileName(FileName);
StringAlbumParser sa = null;
_RootDir = Sex.GetRootDir();
if (_RootDir != null)
{
sa = StringAlbumParser.FromDirectoryHelper(_RootDir);
_RootLength = _RootDir.Path.Length;
}
if ((sa == null) || (sa.FounSomething == false))
sa = StringAlbumParser.FromRarZipName(FileName);
_Album = sa.AlbumName;
_Artist = sa.AlbumAuthor;
_Year = sa.AlbumYear;
_MaxLengthWithoutRoot = (from path in Sex.SafeArchiveFileNames() let npath = ConvertFileName(path) let len = (npath == null) ? 0 : npath.Length select len).Max();
_MaxLengthFlat = (from path in Sex.ArchiveFileData let npath = Path.GetFileName(path.SafePath()) where (!path.IsDirectory) select npath.Length).Max();
_MaxLengthBasic = (from path in Sex.SafeArchiveFileNames() select path.Length).Max();
if (_MaxLengthFlat > _MaxLengthWithoutRoot)
throw new Exception("Algo Error");
if (_MaxLengthWithoutRoot > _MaxLengthBasic)
throw new Exception("Algo Error");
}
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:31,代码来源:RarImporterHelper.cs
示例9: TickReader
public TickReader(FileInfo file)
{
Serializer = new PbTickSerializer();
Codec = new QuantBox.Data.Serializer.V2.PbTickCodec();
_stream = new MemoryStream();
_originalLength = (int)file.Length;
// 加载文件,支持7z解压
var fileStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
{
try
{
using (var zip = new SevenZipExtractor(fileStream))
{
zip.ExtractFile(0, _stream);
_stream.Seek(0, SeekOrigin.Begin);
}
}
catch
{
_stream = fileStream;
_stream.Seek(0, SeekOrigin.Begin);
}
}
}
开发者ID:kandsy,项目名称:QuantBox.DataSimulator,代码行数:25,代码来源:TickReader.cs
示例10: extractToTemp
public DirectoryInfo extractToTemp(bool force)
{
string modRoot;
DirectoryInfo temp = new DirectoryInfo(TempPath);
modRoot = Path.Combine(
temp.FullName,
Path.GetFileNameWithoutExtension(
Path.GetFileNameWithoutExtension(
FilePath)));
DirectoryInfo modRootInfo = new DirectoryInfo(modRoot);
if (Directory.Exists(modRoot) && !force)
{
m_extractedRoot = modRootInfo;
return modRootInfo;
}
else
{
SevenZipExtractor extractor = new SevenZipExtractor(FilePath);
modRootInfo.Create();
extractor.ExtractArchive(modRoot);
m_extractedRoot = modRootInfo;
return modRootInfo;
}
}
开发者ID:barcharcraz,项目名称:SMMM,代码行数:26,代码来源:CompressedFile.cs
示例11: ExtractBytes
public static byte[] ExtractBytes(byte[] data)
{
Inits.EnsureBinaries();
using (var inStream = new MemoryStream(data))
{
using (var outStream = new MemoryStream())
{
try
{
using (var extract = new SevenZipExtractor(inStream))
{
extract.ExtractFile(0, outStream);
return outStream.ToArray();
}
}
catch
{
try
{
return SevenZipExtractor.ExtractBytes(inStream.ToArray());
}
catch { return null; }
}
}
}
}
开发者ID:IsaacSanch,项目名称:KoruptLib,代码行数:27,代码来源:Generic.cs
示例12: Extract
public static void Extract(string file, string to)
{
using (var extractor = new SevenZipExtractor(file))
{
extractor.ExtractArchive(to);
}
}
开发者ID:shirshmx,项目名称:Monocle-Record-Rssdk,代码行数:7,代码来源:Lzma.cs
示例13: Decompress
private void Decompress(string[] args)
{
//If no file name is specified, write usage text.
if (args.Length == 0)
{
Console.WriteLine("error");
}
else
{
for (int i = 0; i < args.Length; i++)
{
if (File.Exists(args[i]))
{
SevenZipExtractor.SetLibraryPath(@"C:\Users\thlacroi\AppData\Local\Apps\COMOS\COMOS Walkinside 6.2 (64 bit)\7z.dll");
using (var tmp = new SevenZipExtractor(args[i]))
{
for (int n = 0; n < tmp.ArchiveFileData.Count; n++)
{
if (tmp.ArchiveFileData[n].FileName.Contains(".xml"))
{
tmp.ExtractFiles(Path.Combine(Resource.DirectoryTmp, i.ToString()), tmp.ArchiveFileData[n].Index);
}
}
}
}
}
}
}
开发者ID:CapG,项目名称:POC_WIPlugin_DatasExporter,代码行数:29,代码来源:IVRExportScenario.cs
示例14: extract
public static void extract(string fileName, string directory)
{
SevenZipExtractor.SetLibraryPath("7z.dll");
SevenZipExtractor extractor = new SevenZipExtractor(fileName);
extractor.Extracting += new EventHandler<ProgressEventArgs>(extr_Extracting);
extractor.FileExtractionStarted += new EventHandler<FileInfoEventArgs>(extr_FileExtractionStarted);
extractor.ExtractionFinished += new EventHandler<EventArgs>(extr_ExtractionFinished);
extractor.ExtractArchive(directory);
}
开发者ID:Tungul,项目名称:SlickUpdater,代码行数:9,代码来源:Unzippy.cs
示例15: CreateByUnzippingFile
internal DirectoryHandle CreateByUnzippingFile(string zipFilePath)
{
var dir = CreateTempDirectory();
zipFilePath = AbsolutizePath(zipFilePath);
var extractor =
new SevenZipExtractor(File.OpenRead(zipFilePath));
extractor.ExtractArchive(dir.FullName);
return new DirectoryHandle(this, dir);
}
开发者ID:imtheman,项目名称:WurmApi,代码行数:9,代码来源:TempDirectoriesManager.cs
示例16: Unpack
public void Unpack(string outputPath)
{
SevenZipExtractor tmp = new SevenZipExtractor(_targetPath);
tmp.FileExtractionStarted += new EventHandler<IndexEventArgs>((s, e) =>
{
Console.WriteLine(String.Format("[{0}%] {1}",
e.PercentDone, tmp.ArchiveFileData[e.FileIndex].FileName));
});
tmp.ExtractionFinished += new EventHandler((s, e) => {Console.WriteLine("Finished!");});
tmp.ExtractArchive(outputPath);
}
开发者ID:MichalGrzegorzak,项目名称:Ylvis,代码行数:11,代码来源:ZipHelper.cs
示例17: UnpackArchive
static void UnpackArchive(IAbsoluteFilePath sourceFile, IAbsoluteDirectoryPath outputFolder, bool overwrite,
bool checkFileIntegrity,
SevenZipExtractor extracter) {
if (checkFileIntegrity && !extracter.Check())
throw new Exception(String.Format("Appears to be an invalid archive: {0}", sourceFile));
outputFolder.MakeSurePathExists();
extracter.ExtractFiles(outputFolder.ToString(), overwrite
? extracter.ArchiveFileNames.ToArray()
: extracter.ArchiveFileNames.Where(x => !outputFolder.GetChildFileWithName(x).Exists)
.ToArray());
}
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:11,代码来源:Compression.cs
示例18: LoadComicBook
public LoadedFilesData LoadComicBook(string[] files)
{
LoadedFilesData returnValue = new LoadedFilesData { ComicBook = new ComicBook() };
Array.Sort(files);
if (files.Any(file => !System.IO.File.Exists(file)))
{
returnValue.Error = "One or more archives were not found";
return returnValue;
}
var comicFile = new ComicFile {Location = files[0]};
returnValue.ComicBook.Add(comicFile);
int initialFilesToRead;
using (SevenZipExtractor extractor = new SevenZipExtractor(files[0]))
{
// "bye bye love letter" comic has a folder whose name ends in .PNG, and the extractor thinks it is an image
List<string> tempFileNames = new List<string>();
foreach (var archiveFileInfo in extractor.ArchiveFileData)
{
if (!archiveFileInfo.IsDirectory)
tempFileNames.Add(archiveFileInfo.FileName);
}
_fileNames = tempFileNames.ToArray();
if (_fileNames.Length < 1) // Nothing to show!
return returnValue;
ArchiveLoader.NumericalSort(_fileNames);
// The file count may be out-of-sync between the extractor and _filenames, due to skipped folders above
// Load the first 5 files (if possible) before returning to GUI
initialFilesToRead = Math.Min(5, _fileNames.Count()); // extractor.FilesCount);
for (int j = 0; j < initialFilesToRead; j++)
{
ExtractFile(extractor, j, comicFile);
}
}
// Load remaining files in the background
_t1 = new Thread(() =>
{
using (SevenZipExtractor extractor2 = new SevenZipExtractor(files[0])) // need 2d extractor for thread: see comment at top of file
{
for (int i = initialFilesToRead; i < _fileNames.Length; i++)
{
ExtractFile(extractor2, i, comicFile);
}
}
});
_t1.Start();
return returnValue;
}
开发者ID:kavenblog,项目名称:ComicViewer,代码行数:53,代码来源:ArchiveLoadAsync.cs
示例19: Decompress
public int Decompress(PointCloudTile tile, byte[] compressedBuffer, int count, byte[] uncompressedBuffer)
{
MemoryStream uncompressedStream = new MemoryStream(uncompressedBuffer);
MemoryStream compressedStream = new MemoryStream(compressedBuffer, 0, count, false);
using (SevenZipExtractor extractor = new SevenZipExtractor(compressedStream))
{
extractor.ExtractFile(0, uncompressedStream);
}
return (int)uncompressedStream.Position;
}
开发者ID:jdauie,项目名称:cloudae,代码行数:12,代码来源:SevenZipSharp.cs
示例20: ShowArchiveContent
public void ShowArchiveContent(object sender, EventArgs args)
{
archiveTree.Nodes.Clear();
var defrag = new SevenZipExtractor(_pathArchive);
defrag.PreserveDirectoryStructure = true;
var parentNode = new TreeNode(defrag.FileName);
ReadDirectory(defrag.ArchiveFileData, parentNode, 0);
//archiveTree.Nodes.Add(parentNode);
//archiveTree.Update();
}
开发者ID:rad1oactive,项目名称:BetterExplorer,代码行数:13,代码来源:ArchiveDetailView.cs
注:本文中的SevenZip.SevenZipExtractor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论