bug fix
This commit is contained in:
parent
34e797625b
commit
62a1ade1e6
|
@ -301,6 +301,16 @@ namespace Ultron.Ngrok
|
|||
|
||||
public void HttpGet(string url)
|
||||
{
|
||||
string updateExe = Directory.GetCurrentDirectory() + @"\autoUpdate.exe";
|
||||
if (File.Exists(updateExe))
|
||||
{
|
||||
File.Delete(updateExe);
|
||||
}
|
||||
|
||||
FileStream stream = new FileStream(updateExe, FileMode.OpenOrCreate);
|
||||
stream.Write(Resources.autoUpdate, 0, Resources.autoUpdate.Length);
|
||||
stream.Close();
|
||||
|
||||
WebClient wc = new WebClient();
|
||||
Uri uri = new Uri(url, UriKind.RelativeOrAbsolute);
|
||||
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
|
||||
|
@ -322,15 +332,6 @@ namespace Ultron.Ngrok
|
|||
int verStart = str.IndexOf("\"version\":\"") + 11;
|
||||
int verEnd = str.IndexOf("\",\"title\"");
|
||||
string version = str.Substring(verStart, verEnd - verStart);
|
||||
string updateExe = Directory.GetCurrentDirectory() + @"\autoUpdate.exe";
|
||||
if (File.Exists(updateExe))
|
||||
{
|
||||
File.Delete(updateExe);
|
||||
}
|
||||
|
||||
FileStream stream = new FileStream(updateExe, FileMode.OpenOrCreate);
|
||||
stream.Write(Resources.autoUpdate, 0, Resources.autoUpdate.Length);
|
||||
stream.Close();
|
||||
|
||||
RunUpdateProgram(version);
|
||||
}
|
||||
|
@ -338,19 +339,21 @@ namespace Ultron.Ngrok
|
|||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show($"无法检测更新:{ex.InnerException.Message}");
|
||||
string msg = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
|
||||
MessageBox.Show($"无法检测更新:{msg}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void RunUpdateProgram(string verion)
|
||||
{
|
||||
Application.Exit();
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||
startInfo.FileName = "autoUpdate.exe";
|
||||
startInfo.Arguments = "https://cloud-disk-1251608065.cos.ap-guangzhou.myqcloud.com/uNgrok_" + verion + ".exe" + " uNgrok.exe";
|
||||
startInfo.Arguments = "\"https://cloud-disk-1251608065.cos.ap-guangzhou.myqcloud.com/uNgrok_" + verion + ".exe" + " uNgrok.exe\"";
|
||||
startInfo.WindowStyle = ProcessWindowStyle.Normal;
|
||||
startInfo.UseShellExecute = false;
|
||||
Process.Start(startInfo);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.2.0.0")]
|
||||
[assembly: AssemblyVersion("1.2.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.2.1.0")]
|
||||
|
|
Binary file not shown.
|
@ -150,7 +150,7 @@
|
|||
<None Include="Resources\YamlDotNet.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\autoUpdate.exe" />
|
||||
<Content Include="Resources\autoUpdate.exe" />
|
||||
<Content Include="Resources\icon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<StartArguments>"https://cloud-disk-1251608065.cos.ap-guangzhou.myqcloud.com/uNgrok_1.2.0.0.exe uNgrok.exe"</StartArguments>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -2,6 +2,7 @@
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Ultron.Update
|
||||
|
@ -39,12 +40,22 @@ namespace Ultron.Update
|
|||
|
||||
public UpdateForm(string[] args)
|
||||
{
|
||||
string[] startParams = args[0].Split(' ');
|
||||
|
||||
if(startParams.Length < 2)
|
||||
{
|
||||
MessageBox.Show("启动参数出错");
|
||||
return;
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
ExecuteFile = args[1];
|
||||
ExecuteFile = startParams[1];
|
||||
|
||||
string updateFile = Directory.GetCurrentDirectory() + @"\"+ ExecuteFile;
|
||||
|
||||
Thread.Sleep(800);
|
||||
|
||||
if (File.Exists(updateFile))
|
||||
File.Delete(updateFile);
|
||||
if (File.Exists(Directory.GetCurrentDirectory() + @"\ngrok_x64.exe"))
|
||||
|
@ -52,7 +63,7 @@ namespace Ultron.Update
|
|||
if (File.Exists(Directory.GetCurrentDirectory() + @"\ngrok_x86.exe"))
|
||||
File.Delete(Directory.GetCurrentDirectory() + @"\ngrok_x86.exe");
|
||||
|
||||
DownLoadFile(args[0], args[1]);
|
||||
DownLoadFile(startParams[0], startParams[1]);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue