Esempio n. 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string[] args        = Environment.GetCommandLineArgs();
            var      localFolder = System.IO.Path.GetDirectoryName(args[1]);
            var      filename    = System.IO.Path.GetFileName(args[1]);

            var fileDisplayName = filename.Replace(".spsync", string.Empty);
            var extension       = System.IO.Path.GetExtension(fileDisplayName);

            if (fileDisplayName.Length > 12)
            {
                fileDisplayName = fileDisplayName.Substring(0, 12);
            }
            TextBlockStatus.Text = String.Format("Downloading '{0}(...){1}'...", fileDisplayName, extension);

            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object state)
            {
                try
                {
                    SyncManager sync = new SyncManager(localFolder);
                    sync.DownloadFile(filename);
                }
                catch { }
                finally
                {
                    this.Dispatcher.Invoke(new Action(delegate
                    {
                        System.Diagnostics.Process.GetCurrentProcess().Kill();
                    }));
                }
            }));
        }