📜 ⬆️ ⬇️

Simplify life: C # auto-unpacking service

hate This, of course, is not an article, but a small travel note, but nonetheless. It so happened that 99% of the archives get on my computer to be immediately unpacked in order to get to their contents. And if in a safari make it itself does for me, then in windows you have to click an item in the context menu every time.

At some point I was sick of it and I wrote a simple service that unpacks everything on my own. It seemed to me convenient and I decided to share with the people.


What it looks like


There is a service in the system. image
')
The service monitors the specified folders and monitors the creation of files with specified extensions (by default, rar and zip , set by the Extentions parameter). As soon as the file has appeared, winrar is launched (you can configure another archiver), which unpacks them.

How it works


Everything is configured via the monitors.cfg config in the ini file format
[WinRar]
c:\Program Files\WinRAR\WinRAR.exe

[Folders]
c:\downloads
c:\distrib

Config can be edited on the fly, the service itself loads changes from it, no need to reload anything.

The file system is monitored via FileSystemWatcher
  1. foreach ( var watcher in monitoringFolders.Where ( Directory .Exists) .Select (folder => new FileSystemWatcher (folder) {IncludeSubdirectories = true }))
  2. {
  3. watcher.Created + = WatcherHandler;
  4. _watchers.Add (watcher);
  5. }
* This source code was highlighted with Source Code Highlighter .


Winrar is launched with the keys x -ad -o + - unpacking into a folder with the same name with the replacement of files.

How to install

Links

  1. Sources
  2. Binary
Thanks for attention.

Source: https://habr.com/ru/post/124809/


All Articles