Files
VRCX/Dotnet/Update.cs
Ethan Cordray 2e9db3153d NET 8 Upgrade (#687)
* Initial .NET8 Upgrade

* Initial GitHub Actions Cleanup

* Fix Desktop Notifications

* Fix throw warning

* Upgrade vunerable transative nuget packages

* Fix warnings with registry overflow

* Adjust async/await usage for configRepository

* Fix TTS voice name and app auto start

* Install .NET 8 with setup

I regret NSIS

* Remove no longer needed System/MS references (included in dotnet sdk)

* Surpress stackalloc in loop warning, that code scares me.

* Removed unused SharpDX packages

* Ignore WebClient warning, hopefully this project doesn't move past NET 8

* Fixed terrifying code

* GenerateAssemblyInfo

* Trimmed editor config to only silence warning.

* Fix open webpage

* Fix updater

---------

Co-authored-by: DubyaDude <ushafiq141@gmail.com>
Co-authored-by: Natsumi <cmcooper123@hotmail.com>
2023-11-22 01:41:57 +13:00

59 lines
2.0 KiB
C#

// Copyright(c) 2019-2022 pypy, Natsumi and individual contributors.
// All rights reserved.
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
using System;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;
namespace VRCX
{
internal class Update
{
private static readonly string VRCX_Setup_Executable = Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe");
private static readonly string Update_Executable = Path.Combine(Program.AppDataDirectory, "update.exe");
public static void Check()
{
if (Process.GetProcessesByName("VRCX_Setup").Length > 0)
Environment.Exit(0);
var setupHash = Path.Combine(Program.AppDataDirectory, "sha256sum.txt");
if (File.Exists(setupHash))
File.Delete(setupHash);
var tempDownload = Path.Combine(Program.AppDataDirectory, "tempDownload.exe");
if (File.Exists(tempDownload))
File.Delete(tempDownload);
if (File.Exists(VRCX_Setup_Executable))
File.Delete(VRCX_Setup_Executable);
if (File.Exists(Update_Executable))
Install();
}
private static void Install()
{
try
{
File.Move(Update_Executable, VRCX_Setup_Executable);
var VRCXProcess = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = VRCX_Setup_Executable,
Arguments = "/S",
UseShellExecute = true,
WorkingDirectory = Program.AppDataDirectory
}
};
VRCXProcess.Start();
Environment.Exit(0);
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Update failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}