File size: 2,055 Bytes
e26fba6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.IO;
namespace MovieFinder.UpService
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
bool createdNew;
var mutex = new Mutex(true, "moviefinderupdate", out createdNew);
if (!createdNew)
return;
Thread.Sleep(2000);
Execute();
}
static void Execute()
{
try
{
var allProcesses = Process.GetProcessesByName("MovieFinder.Client");
foreach (var process in allProcesses)
{
if (process.MainModule != null && "MovieFinder.Client.exe".Equals(process.MainModule.ModuleName, StringComparison.InvariantCultureIgnoreCase))
{
process.Kill();
Thread.Sleep(2000);
if (!process.HasExited)
Thread.Sleep(5000);
if (!process.HasExited)
return;
break;
}
}
var files = Directory.GetFiles(Application.StartupPath);
foreach (var file in files)
{
if (!file.Contains("MovieFinder.UpService.exe"))
{
File.Copy(file, Path.Combine(Directory.GetParent(Application.StartupPath).FullName,
Path.GetFileName(file)), true);
}
}
var app = Path.Combine(Directory.GetParent(Application.StartupPath).FullName, "MovieFinder.Client.exe");
Process.Start(app);
}
catch { }
}
}
}
|