Example #1
0
        public async static Task CreateServerWin()
        {
            if (!File.Exists("../steamcmd/steamcmd.exe"))
            {
                if (!Directory.Exists("../steamcmd/"))
                {
                    Directory.CreateDirectory("../steamcmd");
                }
                else
                {
                    TmpDir.CleanDirRecursive("../steamcmd/");
                }
                Console.WriteLine("Downloading steamcmd");
                using (TmpDir dir = new TmpDir("."))
                {
                    using (WebClient client = new WebClient())
                    {
                        client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(LoadingBar.DownloadProgressCallback);
                        await client.DownloadFileTaskAsync("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip", dir.dirName + "steamcmd.zip");

                        Console.Write("\n\r");
                    }
                    ZipFile.ExtractToDirectory(dir.dirName + "steamcmd.zip", "../steamcmd/");
                }
            }
            using (Process process = new Process())
            {
                process.StartInfo.CreateNoWindow         = false;
                process.StartInfo.RedirectStandardError  = false;
                process.StartInfo.RedirectStandardInput  = false;
                process.StartInfo.RedirectStandardOutput = false;
                process.StartInfo.FileName  = "../steamcmd/steamcmd.exe";
                process.StartInfo.Arguments = "+login anonymous +force_install_dir \"../\" +app_update 786920 -beta beta validate +quit";
                process.Start();
                process.WaitForExit();
            }
        }