public SevenZipWorking() { // Toggle between the x86 and x64 bit dll string dllPath = Path.Combine(FileUtil.GetLocalExecutionFullPah(), "Libraries\\SevenZip", Environment.Is64BitProcess ? "x64" : "x86", "7z.dll"); SevenZipBase.SetLibraryPath(dllPath); }
public static void UnpackArchive(string archiveFile, string unziplocation) { SevenZipBase.SetLibraryPath(@"_lib\7z.dll"); SevenZipExtractor extractor = new SevenZipExtractor(archiveFile); extractor.ExtractArchive(unziplocation); }
/// <summary> /// Extracts a 7z archive at the given path for file loading /// </summary> public static bool ExtractArchive(string path) { Console.WriteLine(Directory.GetCurrentDirectory()); SevenZipBase.SetLibraryPath(IntPtr.Size == 8 ? Path.Combine(Directory.GetCurrentDirectory(), @"7z64.dll") : Path.Combine(Directory.GetCurrentDirectory(), @"7z.dll")); var directory = Path.GetDirectoryName(path); var filename = Path.GetFileNameWithoutExtension(path); if (directory == null) { return(false); } var newDirectory = Path.Combine(directory, filename); if (Directory.Exists(newDirectory)) { Directory.Delete(newDirectory, true); } Directory.CreateDirectory(newDirectory); using (var tmp = new SevenZipExtractor(path)) { foreach (var fileinfo in tmp.ArchiveFileData) { tmp.ExtractFiles(newDirectory, fileinfo.Index); } } return(true); }
public static LibraryFeature Install() { var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Environment.Is64BitProcess ? "7z-x64.dll" : "7z-x86.dll"); SevenZipBase.SetLibraryPath(path); return(new LibraryFeature()); }
public IObservable <Progress> Transfer(params string[] args) { string source = args[0]; string destination = args[1]; Init(); return((IObservable <Progress>) this.progress); void Init() { if (Directory.Exists(source) && Directory.GetParent(destination).Exists) { SevenZipBase.SetLibraryPath(this.dll7z); SevenZipCompressor sevenZipCompressor = new SevenZipCompressor(source); DateTime start = new DateTime(); sevenZipCompressor.CompressionMode = SevenZip.CompressionMode.Create; sevenZipCompressor.TempFolderPath = Path.GetTempPath(); sevenZipCompressor.ArchiveFormat = OutArchiveFormat.SevenZip; sevenZipCompressor.Compressing += (a, b) => this.progress.OnNext(new Progress(start, (long)b.PercentDone, 100L)); sevenZipCompressor.BeginCompressDirectory(source, destination); } else { throw new Exception("Source does " + (Directory.Exists(source) ? string.Empty : "not") + " exist & destination's parent does " + (File.Exists(destination) ? string.Empty : "not") + " exist."); } } }
public IObservable <Progress> Transfer(params string[] args) { string source = args[0]; string destination = args[1]; Init(); return((IObservable <Progress>) this.progress); void Init() { if (File.Exists(source) && Directory.GetParent(destination).Exists) { Directory.CreateDirectory(destination); SevenZipBase.SetLibraryPath(this.dll7z); SevenZipExtractor sevenZipExtractor = new SevenZipExtractor(source); int max = sevenZipExtractor.ArchiveFileData.Count; DateTime start = new DateTime(); int current = 0; sevenZipExtractor.FileExtractionStarted += (EventHandler <FileInfoEventArgs>)((a, b) => { ++current; this.progress.OnNext(new Progress(start, (long)current, (long)max)); }); sevenZipExtractor.BeginExtractArchive(destination); } else { throw new Exception("Source does " + (File.Exists(source) ? string.Empty : "not") + " exist & destination parent does " + (Directory.GetParent(destination).Exists ? string.Empty : "not") + " exist."); } } }
protected override void EndProcessing() { var libraryPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(GetType().Assembly.Location), Environment.Is64BitProcess ? "7z64.dll" : "7z.dll"); SevenZipBase.SetLibraryPath(libraryPath); var queue = new BlockingCollection <object>(); var worker = CreateWorker(); worker.Queue = queue; _thread = StartBackgroundThread(worker); foreach (var o in queue.GetConsumingEnumerable()) { var record = o as ProgressRecord; var errorRecord = o as ErrorRecord; if (record != null) { WriteProgress(record); } else if (errorRecord != null) { WriteError(errorRecord); } else { WriteObject(o); } } _thread.Join(); }
protected override void BeginProcessing() { base.BeginProcessing(); RegisterInputType <ArchiveEntry>(ProcessArchive); RegisterInputType <FileInfo>(ProcessArchive); // if OutputPath is not provided, use current filesystem path. if (OutputPath == null) { OutputPath = PscxPathInfo.FromPathInfo(this.CurrentProviderLocation(FileSystemProvider.ProviderName)); // todo: localize WriteVerbose("Using FileSystemProvider current location for OutputPath: " + OutputPath); } string sevenZDll = PscxContext.Instance.Is64BitProcess ? "7z64.dll" : "7z.dll"; string sevenZPath = System.IO.Path.Combine(PscxContext.Instance.Home, sevenZDll); if (SevenZipBase.CurrentLibraryFeatures == LibraryFeature.None) { Trace.Assert(File.Exists(sevenZPath), sevenZPath + " not found or inaccessible."); SevenZipBase.SetLibraryPath(sevenZPath); // can only call this once per appdomain } WriteDebug("7zip path: " + sevenZPath); WriteDebug("7zip features: " + SevenZipBase.CurrentLibraryFeatures); }
public static void DeCompressRarBy7z(string rarFileName, string saveDir) { SevenZipBase.SetLibraryPath(GlobalEnvironment.BasePath + @"/" + "7z.dll"); var extractor = new SevenZipExtractor(rarFileName); extractor.ExtractArchive(saveDir); }
/// <summary> /// Extract resource to _zipPath /// </summary> /// <param name="resourceName">name of zip to extract</param> private static void ExtractZip(string resourceName) { //Get the dll path for 7z var sevenZipPath = Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Environment.Is64BitProcess ? "x64" : "x86", "7z.dll"); SevenZipBase.SetLibraryPath(sevenZipPath); var file = new SevenZipExtractor(resourceName); file.FileExtractionFinished += (sender, args) => { //args.PercentDone returns a byte for some f*****g reason, try to convert to an int int percentDone = int.TryParse(args.PercentDone.ToString(), out int test) ? test : 0; if (percentDone >= 100) { percentDone = 100; } worker.ReportProgress((100 * _stage / _stages) + percentDone / _stages, percentDone); if (worker.CancellationPending) { args.Cancel = true; } mre.WaitOne(); }; //Start extracting file.ExtractArchive(_unpackPath); }
public static AppSettings AddPcsx2ConfiguratorCoreServices(this IServiceCollection services, IConfiguration configuration) { var settings = new AppSettings(); configuration.Bind(settings, options => options.BindNonPublicProperties = true); services.AddTransient(provider => settings); services.AddSingleton <IProcessHelpers, WindowsProcessHelpers>(); services.AddSingleton <IFileHelpers, FileHelpers>(); SevenZipBase.SetLibraryPath($"{settings.SevenZipLibraryPath}\\7za.dll"); Iso7zIdentificationService.SetLibraryPath(settings.SevenZipLibraryPath); LibGit2Sharp.GlobalSettings.NativeLibraryPath = settings.GitLibraryPath; services.AddTransient(provider => new FileIniDataParser()); services.AddSingleton <IGameLibraryService, GameLibraryService>(); services.AddSingleton <IEmulationService, EmulationService>(); services.AddSingleton <IConfigurationService, ConfigurationService>(); services.AddSingleton <IDiscIdLookupService, RedumpDiscIdLookupService>(); services.AddSingleton <ICoverService, ChainedCoverService>(); services.AddSingleton <IIdentificationService, Iso7zIdentificationService>(); services.AddSingleton <IVersionManagementService, VersionManagementService>(); services.AddSingleton <IRemoteConfigService, RemoteConfigService>(); return(settings); }
internal void worker_DoworkConvertFile(object sender, DoWorkEventArgs e) { try { if (!Validate.IsValid.IsSelectcom1(P2.ComboBox) || !Validate.IsValid.IsSelectcom2(P2.ComboBox1) || !Validate.IsValid.IsSeathZn(P2.TextBox)) { Worker.CancelAsync(); } else { var item = (SeathPath.PathStart)P2.Dispatcher.Invoke(() => P2.ComboBox.SelectedValue); var item1 = (SeathPath.PathStart)P2.Dispatcher.Invoke(() => P2.ComboBox1.SelectedValue); P2.Dispatcher.Invoke(() => P2.Status.Text = @"Собираем архивы в папках!!!"); string[] filesarj = Arh.Seath.Seatharj(item.NamePath, item1.PathNow); var proc = (100.0f / filesarj.Length); if (Capacity.Capacity.GetOsBit() == "x64") { SevenZipBase.SetLibraryPath(Configuration.Conf.PathDll64); } else { SevenZipBase.SetLibraryPath(Configuration.Conf.PathDll32); } foreach (var filearj in filesarj) { Worker.ReportProgress((int)(proc * 100.0f)); P2.Dispatcher.Invoke(() => P2.Status.Text = @"Осуществляем поиск файла!!!"); Stream = File.OpenRead(filearj); Strf = new SevenZipExtractor(Stream); foreach (var entry in Strf.ArchiveFileNames) { Createnamefile = new FileStream(Configuration.Conf.RunTimeDerectory + entry, FileMode.Create); Strf.ExtractFile(entry, Createnamefile); Createnamefile.Close(); using (FileStrim = new StreamReader(Createnamefile.Name)) { while (!FileStrim.EndOfStream) { var readLine = FileStrim.ReadLine(); if (readLine != null) { if (readLine.Contains(P2.Dispatcher.Invoke(() => P2.TextBox.Text))) { Strf.ExtractFiles(Configuration.Conf.OkPath, entry); } } } } } } } SeathPath.PathSt.FilePath(sender, P2.Dispatcher.Invoke(() => P2.ListFileArh)); Arh.Seath.Delet(); Dispose(); } catch (Exception n) { MessageBox.Show(n.ToString()); } }
static void Main(string[] args) { SevenZipBase.SetLibraryPath(@"F:\workspaces\vs\DCoTETools\roslynextracter\bin\Debug\7z.dll"); Directory.CreateDirectory("roslyntemp"); using (MemoryStream ms = new MemoryStream()) { using (SevenZipExtractor extractor = new SevenZipExtractor("RoslynSetup.exe")) { extractor.ExtractFile("roslyn.msi", ms); File.WriteAllBytes("roslyn.msi", ms.ToArray()); } } string roslyntemp = Path.Combine(Directory.GetCurrentDirectory(), "roslyntemp"); string parameters = string.Empty; parameters = string.Format(@"/a {0} /qb TARGETDIR=""{1}"" REINSTALLMODE=amus", "roslyn.msi", roslyntemp); Process process = Process.Start("msiexec", parameters); process.WaitForExit(); File.Delete("roslyn.msi"); File.Copy(Path.Combine(roslyntemp, @"Reference Assemblies\Microsoft\Roslyn\v1.0\Roslyn.Compilers.CSharp.dll"), "Roslyn.Compilers.CSharp.dll"); File.Copy(Path.Combine(roslyntemp, @"Reference Assemblies\Microsoft\Roslyn\v1.0\Roslyn.Compilers.dll"), "Roslyn.Compilers.dll"); Directory.Delete("roslyntemp", true); }
private void btnZipPW_Click(object sender, EventArgs e) { //SevenZipCompressor.SetLibraryPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "7z.dll")); string dllPath = Environment.Is64BitProcess ? Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "x64", "7z.dll") : Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "x86", "7z.dll"); SevenZipBase.SetLibraryPath(dllPath); //SevenZipBase.SetLibraryPath(path); // string dll = @"E:\WindownFormApplication\WFA-WebClient\WFA-WebClient\bin\Debug\x64\7z.dll"; // SevenZipBase.SetLibraryPath(Path.Combine( //Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Environment.CurrentDirectory, //"7za.dll")); SevenZipCompressor compressor = new SevenZipCompressor(); //string startPath = @"E:\WindownFormApplication\WFA-WebClient\WFA-WebClient\bin\Release\qw"; string password = @"a"; string destinationFile = @"E:\WindownFormApplication\WFA-WebClient\WFA-WebClient\bin\Release\tesaat.zip"; string[] sourceFiles = Directory.GetFiles(@"E:\WindownFormApplication\WFA-WebClient\WFA-WebClient\bin\Release\aaa\"); if (String.IsNullOrWhiteSpace(password)) { compressor.CompressFiles(destinationFile, sourceFiles); } else { //optional compressor.EncryptHeaders = true; compressor.CompressFilesEncrypted(destinationFile, password, sourceFiles); } }
public static string DecryptConfig(string configPath, string programFolder) { string libPath = Path.Combine(programFolder, "inc.dll"); string libPath64 = Path.Combine(programFolder, "inc_64.dll"); SevenZipBase.SetLibraryPath(libPath); string decrypted = null; SevenZipExtractor ex = new SevenZipExtractor(configPath, decryptionKey); MemoryStream extracted = new MemoryStream(); try { ex.ExtractFile("conf.xml", extracted); } catch { //32bit dll load failed try { SevenZipBase.SetLibraryPath(libPath64); ex.ExtractFile("conf.xml", extracted); } catch { //64 bit dll load failed! return(null); } } extracted.Position = 0; using (StreamReader sr = new StreamReader(extracted)) { decrypted = sr.ReadToEnd(); } extracted.Close(); return(decrypted); }
void extractArchive() { var f = Directory.GetFiles("Temp", "*.001"); InstallBar.Value = 0; isSettingsButtonDisabled = true; isStartButtonDisabled = true; isCloseButtonDisabled = true; SettingsBtn.Image = Resources.BTN_CONFIG_DISABLED; StartBtn.Image = Resources.BTN_START_DISABLED; CloseBtn.Image = Resources.BTN_CLOSE_DISABLED; Thread thread2 = new Thread(() => { SevenZipBase.SetLibraryPath("7z.dll"); SevenZipExtractor se = new SevenZipExtractor(f[0]); se.ExtractionFinished += new EventHandler <EventArgs>(se_ExtractionFinished); se.Extracting += new EventHandler <ProgressEventArgs>(se_Extracting); se.BeginExtractArchive(Directory.GetCurrentDirectory()); }); thread2.Start(); }
public FileDataSimulator(Framework framework) : base(framework) { if (Environment.Is64BitProcess) { SevenZipBase.SetLibraryPath("7z64.dll"); } else { SevenZipBase.SetLibraryPath("7z.dll"); } RunOnSubscribe = true; id = 50; name = "QBDataSimulator"; description = "QuantBox Data Simulator"; url = "www.smartquant.cn"; _barFilter = new BarFilter(); SubscribeAsk = true; SubscribeBid = true; SubscribeTrade = true; Series = new List <IDataSeries>(); Processor = new DataProcessor(); DateTime1 = DateTime.MinValue; DateTime2 = DateTime.MaxValue; }
} // Установка void Install_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { DLTime.Reset(); progressBar1.Value = 0; //сброс progressBar1 SevenZipBase.SetLibraryPath(varPath.Launcherfolder + "7z.dll"); // фурыкает InstallProgress(); } // загрузка завершена
private static void Compress(string archiveName, string[] fileList) { SevenZipBase.SetLibraryPath(@".\7z.dll"); var compressor = new SevenZipCompressor(); compressor.CompressFiles(archiveName, fileList); }
/// <summary> /// gets the number of pages of the cbz/cbr archive /// </summary> private int ReadPageCount(string archivePath) { if (File.Exists(archivePath)) { //direct the program to the dependency: 7z.dll (7z64.dll for 64-bit ver.) SevenZipBase.SetLibraryPath(Path.Combine(Environment.CurrentDirectory, "7z.dll")); using (var extractor = new SevenZipExtractor(archivePath)) { //get the sorted archive file list to get the first image //verify that the cover page is an image var fileNames = extractor.ArchiveFileData .Where( file => ImageChecker.IsImageExtension( Path.GetExtension(file.FileName) ) ); fileNames = fileNames.OrderBy(file => file.FileName); //this is the page count return(fileNames.Count()); } } else { Trace.WriteLine("Set Path = " + "<" + filePath + ">" + " is invalid, cannot proceed with page counting process."); FileNotFoundException exc = new FileNotFoundException ( "Set Path = " + "<" + filePath + ">" + " cannot proceed with comic book records access." ); throw exc; } }
public zipManager(string filename) { SevenZipBase.SetLibraryPath(Directory.GetCurrentDirectory() + @"\7z.dll"); init(); fi = new FileInfo(filename); }
protected override void EndProcessing() { SevenZipBase.SetLibraryPath(Utils.SevenZipLibraryPath); var queue = new BlockingCollection <object>(); var worker = CreateWorker(); worker.Queue = queue; _thread = StartBackgroundThread(worker); foreach (var o in queue.GetConsumingEnumerable()) { var record = o as ProgressRecord; var errorRecord = o as ErrorRecord; if (record != null) { WriteProgress(record); } else if (errorRecord != null) { WriteError(errorRecord); } else if (o is string) { WriteVerbose((string)o); } else { WriteObject(o); } } _thread.Join(); }
public string CreateZip(Metadata metadata, ConfigAga configAga, string pathDir, String path7Zdll) { string pathProperties = string.Concat(pathDir, Constants.PARAM_PROPERTIES); string pathJson = string.Concat(pathDir, Constants.JSON_METADATA); //create metadata - json string jsonMetadata = JsonConvert.SerializeObject(metadata); File.WriteAllText(pathJson, jsonMetadata); //create param - properties Dictionary <string, string> propertiesParam = new Dictionary <string, string>(); propertiesParam.Add("contentFile", Constants.JSON_METADATA); propertiesParam.Add("timestamp", configAga.timestamp); propertiesParam.Add("certificateId", configAga.certificateId); propertiesParam.Add("secretPassword", configAga.secretPassword); using (StreamWriter file = new StreamWriter(pathProperties)) { if (File.Exists(pathProperties)) { foreach (var entry in propertiesParam) { file.WriteLine("{0}={1}", entry.Key, entry.Value); } } } try { //zip files SevenZipBase.SetLibraryPath(Path.GetFullPath(Path.Combine(path7Zdll, "7z.dll"))); SevenZipCompressor szc = new SevenZipCompressor(); szc.CompressionLevel = CompressionLevel.Ultra; szc.CompressionMode = CompressionMode.Create; string sevenZOutput = string.Concat(pathDir, Constants.FILE_ZIP); string[] pathFiles = { pathJson, pathProperties }; szc.CompressionMode = File.Exists(sevenZOutput) ? SevenZip.CompressionMode.Append : SevenZip.CompressionMode.Create; FileStream archive = new FileStream(sevenZOutput, FileMode.OpenOrCreate, FileAccess.ReadWrite); szc.DirectoryStructure = true; szc.EncryptHeaders = true; szc.DefaultItemName = sevenZOutput; szc.CompressFiles(archive, pathFiles); archive.Close(); return(sevenZOutput); } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } return(null); }
public void Initialize() { this.currentDir = Directory.GetCurrentDirectory(); this.testRessources = Path.GetFullPath(currentDir + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + "Testresources"); this.outDir = Path.GetFullPath(currentDir + "testout"); Directory.CreateDirectory(outDir); SevenZipBase.SetLibraryPath(getLibraryPathFromDirectory(getArchitecture())); }
public Form1() { InitializeComponent(); string basePath = AppDomain.CurrentDomain.BaseDirectory; SevenZipBase.SetLibraryPath(Path.Combine(basePath, Environment.Is64BitProcess ? "x64\\7z.dll" : "x86\\7z.dll")); }
public MainWindow() { DataContext = new MainWindowViewModel(DialogCoordinator.Instance); InitializeComponent(); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; SevenZipBase.SetLibraryPath($@"{AppDomain.CurrentDomain.BaseDirectory}\7z.dll"); }
/// <inheritdoc/> protected override void Execute() { State = TaskState.Header; try { // NOTE: Must do initialization here since the constructor may be called on a different thread and SevenZipSharp is thread-affine SevenZipBase.SetLibraryPath(Locations.GetInstalledFilePath(WindowsUtils.Is64BitProcess ? "7zxa-x64.dll" : "7zxa.dll")); using (var extractor = new SevenZip.SevenZipExtractor(_stream)) { State = TaskState.Data; if (!Directory.Exists(EffectiveTargetDir)) { Directory.CreateDirectory(EffectiveTargetDir); } if (extractor.IsSolid || string.IsNullOrEmpty(SubDir)) { ExtractComplete(extractor); } else { ExtractIndividual(extractor); } } } #region Error handling catch (ObjectDisposedException ex) { // Async cancellation may cause underlying file stream to be closed Log.Warn(ex); throw new OperationCanceledException(); } catch (SevenZipException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(Resources.ArchiveInvalid, ex); } catch (KeyNotFoundException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(Resources.ArchiveInvalid, ex); } catch (ArgumentException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(Resources.ArchiveInvalid, ex); } catch (NullReferenceException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(Resources.ArchiveInvalid, ex); } #endregion State = TaskState.Complete; }
private static void Set7ZipLibraryPath() { if (NativeMethods.Is64Bit()) { SevenZipBase.SetLibraryPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "7z-x64.dll")); } else { SevenZipBase.SetLibraryPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "7z.dll")); } }
protected void initLib() { string cPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).PathFormat(); try { SevenZipBase.SetLibraryPath(Path.Combine(cPath, LIB_FULL)); isReady = true; } catch (Exception ex) { Log.Error("Found problem with library {0} ({1}): `{2}`", LIB_FULL, cPath, ex.Message); } }
static void Initialize() { if (IsInitialized) { return; } // ✅ AppContext.BaseDirectory var sevenZipLibraryPath = Path.Combine(AppContext.BaseDirectory, "7z.dll"); SevenZipBase.SetLibraryPath(sevenZipLibraryPath); IsInitialized = true; }