Вот весь код из form1
:
using System;
using System.IO;
using System.Windows.Forms;
using System.Threading;
using System.Net;
using System.IO.Compression;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Diagnostics.Tracing;
namespace BSCS_Launcher
{
public partial class Form1 : Form
{
private WebClient webClient = null;
const string basPath = @"cstrike";
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
Form6 f6 = new Form6();
f6.ShowDialog(); // Shows Form6 - Launchoptions
}
private void button1_Click(object sender, EventArgs e)
{
string path = @"steamlop.lop";
string cfgpath = @"cstrike/config.cfg";
FileAttributes attributes = File.GetAttributes(cfgpath);
if (File.Exists(path))
{
File.SetAttributes(cfgpath, File.GetAttributes(cfgpath) | FileAttributes.ReadOnly);
var str = File.ReadAllText(path);
System.Diagnostics.Process.Start("hl.exe", arguments: str);
}
else
{
string message = "Launch options not found. Please go into launch options and click double click Reset!!!";
string title = "Launch options error";
MessageBox.Show(message, title);
}
}
private void button3_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.ShowDialog(); // Shows Form2 - Features
}
private void button4_Click(object sender, EventArgs e)
{
Form3 f3 = new Form3();
f3.ShowDialog(); // Shows Form3 - Options
}
private void button5_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://fastxhoster.com/");
}
private void button7_Click(object sender, EventArgs e)
{
Form5 f5 = new Form5();
f5.ShowDialog(); // Shows Form5 - Updatelauncher
// Is file downloading yet?
if (webClient != null)
{
return;
}
var dirdir = new DirectoryInfo($"{basPath}");
if (!dirdir.Exists)
{
webClient = new WebClient();
webClient.DownloadFileCompleted += FileDownloading;
webClient.DownloadFileAsync(new Uri("https://sipi-portfolio.000webhostapp.com/verzija.php"), $"{basPath}/version.php");
}
else
{
webClient = new WebClient();
webClient.DownloadFileCompleted += FileDownloading;
webClient.DownloadFileAsync(new Uri("https://sipi-portfolio.000webhostapp.com/verzija.php"), $"{basPath}/version.php");
} //Ovaj kod treba da se izvrsi tek kada je igracu skinut novi update ukoliko ga je bilo
}
private void FileDownloading(object sender, AsyncCompletedEventArgs e)
{
webClient = null;
string pathfile = $"{basPath}/verzija.php";
string pathfile2 = $"{basPath}/version.php";
var str = File.ReadAllText(pathfile);
var str2 = File.ReadAllText(pathfile2);
if (str != str2)
{
CloseProcessing();
string message = "We found an avilable update for this launcher!";
string title = "Update launcher";
MessageBox.Show(message, title);
}
else
{
CloseProcessing();
string message = "No new updates!";
string title = "Update launcher";
MessageBox.Show(message, title);
}
}
public void CloseProcessing()
{
Form5 f5 = new Form5();
f5.Close(); // Closes Form5 - Updatelauncher
}
}
}
Здесь вы можете видеть, что я создал код для загрузки одного файла с одного веб-сайта, и он должен проверить, имеют ли эти 2 файла одинаковый контекст , если нет, он должен что-то сделать, и если да, он должен сделать что-то снова, в обеих ситуациях он должен закрыть форму 5, но он не закрывается ... Я пытался много кодов, чтобы решить эту проблему, но это не влияет ...
Заранее спасибо ...!