Code Snippet
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using System.IO;
namespace WindowsApplication3
{
public static class Rest
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
public class MyClass
{
public static void gogo()
{
string q = "no";
Process restart2;
DateTime processStartTime = DateTime.Now;
DirectoryInfo di = new DirectoryInfo("Stats");
string a;
string path = "Stats/stats.txt";
restart2 = Process.Start("server.exe");
//Created Folder
if (di.Exists)
{
Console.WriteLine("Ready");
}
else
{
di.Create();
}
while (q != "yes")
{
Thread.Sleep(10000);
if (restart2.HasExited)
{
a = (String.Format("{2} process exited at {0} and ran for {1}", restart2.ExitTime, restart2.ExitTime - processStartTime, (DateTime.Now - restart2.ExitTime)));
restart2 = Process.Start("server.exe");
string appendText = a + Environment.NewLine;
File.AppendAllText(path, appendText);
}
}
}
}
}