diff --git a/Ultron.Ngrok/FormMain.cs b/Ultron.Ngrok/FormMain.cs
index c64c875..d8a322c 100644
--- a/Ultron.Ngrok/FormMain.cs
+++ b/Ultron.Ngrok/FormMain.cs
@@ -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
diff --git a/Ultron.Ngrok/Properties/AssemblyInfo.cs b/Ultron.Ngrok/Properties/AssemblyInfo.cs
index 67a167e..51d6294 100644
--- a/Ultron.Ngrok/Properties/AssemblyInfo.cs
+++ b/Ultron.Ngrok/Properties/AssemblyInfo.cs
@@ -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")]
diff --git a/Ultron.Ngrok/Resources/autoUpdate.exe b/Ultron.Ngrok/Resources/autoUpdate.exe
index 589b54e..052fe05 100644
Binary files a/Ultron.Ngrok/Resources/autoUpdate.exe and b/Ultron.Ngrok/Resources/autoUpdate.exe differ
diff --git a/Ultron.Ngrok/Ultron.Ngrok.csproj b/Ultron.Ngrok/Ultron.Ngrok.csproj
index 93616fa..c57a5c4 100644
--- a/Ultron.Ngrok/Ultron.Ngrok.csproj
+++ b/Ultron.Ngrok/Ultron.Ngrok.csproj
@@ -150,7 +150,7 @@
-
+
diff --git a/Ultron.Update/Ultron.Update.csproj.user b/Ultron.Update/Ultron.Update.csproj.user
new file mode 100644
index 0000000..73ee0e3
--- /dev/null
+++ b/Ultron.Update/Ultron.Update.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ "https://cloud-disk-1251608065.cos.ap-guangzhou.myqcloud.com/uNgrok_1.2.0.0.exe uNgrok.exe"
+
+
\ No newline at end of file
diff --git a/Ultron.Update/UpdateForm.cs b/Ultron.Update/UpdateForm.cs
index 7bcd6aa..c86b4e3 100644
--- a/Ultron.Update/UpdateForm.cs
+++ b/Ultron.Update/UpdateForm.cs
@@ -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]);
}