Auxilium.Classes.Updater.OnDownloadCompleted C# (CSharp) Method

OnDownloadCompleted() private method

private OnDownloadCompleted ( object sender, DownloadDataCompletedEventArgs eventArgs ) : void
sender object
eventArgs System.Net.DownloadDataCompletedEventArgs
return void
        private void OnDownloadCompleted(object sender, DownloadDataCompletedEventArgs eventArgs)
        {
            if (eventArgs.Error != null)
            {
                throw eventArgs.Error;
            }

            string file = Path.Combine(Application.StartupPath, DownloadUrl.Split('/')[DownloadUrl.Split('/').Length - 1]);

            File.WriteAllBytes(file, eventArgs.Result);

            string batch = string.Format(
                "@echo off{1}" +
                "TASKKILL /F /PID {0}{1}" +
                "PING 1.1.1.1 -n 1 -w 2000 >NUL{1}" +
                "DEL %2{1}" +
                "MOVE %1 %2{1}" +
                "%2{1}" +
                "DEL %1{1}" +
                "DEL %3", Process.GetCurrentProcess().Id, Environment.NewLine);
            string batchFile = Path.Combine(Application.StartupPath, "update.bat");

            File.WriteAllText(batchFile, batch);

            ProcessStartInfo info = new ProcessStartInfo(batchFile,
                string.Format("\"{0}\" \"{1}\" \"{2}\"", file, Application.ExecutablePath, batchFile))
                                        {CreateNoWindow = true, UseShellExecute = false};
            Process.Start(info);
        }