Added checking for updates
This commit is contained in:
parent
cc15863e81
commit
5ec6525257
19 changed files with 1231 additions and 100 deletions
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Ookii.Dialogs.Wpf; // ← add this
|
||||
using System.Windows;
|
||||
|
||||
namespace MossyUpdater
|
||||
{
|
||||
|
|
@ -13,60 +8,5 @@ namespace MossyUpdater
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Browse_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dlg = new VistaFolderBrowserDialog
|
||||
{
|
||||
Description = "Select a destination folder",
|
||||
UseDescriptionForTitle = true
|
||||
};
|
||||
|
||||
// ShowDialog returns true if the user clicked OK
|
||||
if (dlg.ShowDialog() == true)
|
||||
FolderTextBox.Text = dlg.SelectedPath;
|
||||
}
|
||||
|
||||
private async void Download_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string url = UrlTextBox.Text.Trim();
|
||||
string folder = FolderTextBox.Text.Trim();
|
||||
string filename = FilenameTextBox.Text.Trim();
|
||||
|
||||
if (string.IsNullOrEmpty(url)
|
||||
|| string.IsNullOrEmpty(folder)
|
||||
|| string.IsNullOrEmpty(filename))
|
||||
{
|
||||
StatusTextBlock.Text = "Please fill in all fields.";
|
||||
StatusTextBlock.Foreground = System.Windows.Media.Brushes.Red;
|
||||
return;
|
||||
}
|
||||
|
||||
string fullPath = Path.Combine(folder, filename);
|
||||
|
||||
try
|
||||
{
|
||||
using var client = new HttpClient();
|
||||
var data = await client.GetByteArrayAsync(url);
|
||||
await File.WriteAllBytesAsync(fullPath, data);
|
||||
|
||||
UnblockFile(fullPath);
|
||||
|
||||
StatusTextBlock.Text = $"Downloaded and unblocked:\n{fullPath}";
|
||||
StatusTextBlock.Foreground = System.Windows.Media.Brushes.Green;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StatusTextBlock.Text = $"Error: {ex.Message}";
|
||||
StatusTextBlock.Foreground = System.Windows.Media.Brushes.Red;
|
||||
}
|
||||
}
|
||||
|
||||
private void UnblockFile(string path)
|
||||
{
|
||||
var zone = path + ":Zone.Identifier";
|
||||
if (File.Exists(zone))
|
||||
File.Delete(zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue