Click here to Skip to main content
15,884,176 members
Articles / Programming Languages / C#

Automatic Zip Extractor

Rate me:
Please Sign up or sign in to vote.
4.87/5 (17 votes)
10 Oct 2013CPOL4 min read 47.7K   2.1K   44  
Automatically unblocks and extracts Zip files in a monitored folder.
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Windows.Threading;
using System.Threading;

namespace AutoExtractor
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private MainWindow window;        

        public App()
        {
        }

        public App(KeyboardHook hook)
        {
            if (hook == null)
                throw new ArgumentNullException("hook");
            hook.KeyCombinationPressed += new EventHandler(hook_KeyCombinationPressed);
        }

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            window = new MainWindow();
            if (AutoExtractor.Properties.Settings.Default.StartMinimizedToTray)
                window.MinimizeToTray();
            else
                window.Show();
        }

        void hook_KeyCombinationPressed(object sender, EventArgs e)
        {
            Dispatcher.Invoke(DispatcherPriority.Normal, new ThreadStart(ShowMainWindow));
        }

        private void ShowMainWindow()
        {
            if (window.Visibility != Visibility.Visible)
            {
                WindowVisibilityHelper.ActivateWindow(window);
                window.ChangedFileControl.Focus();
            }
            else
                window.MinimizeToTray();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Veracity
United States United States
I'm a .NET developer, fluent in C# and VB.NET with a focus on SharePoint and experience in WinForms, WPF, Silverlight, ASP.NET, SQL Server. My roots come from a support/system administrator role so I know my way around a server room as well.

I have a passion for technology and I love what I do.

Comments and Discussions