Skip to content

Commit

Permalink
添加了AutoUpdate模块
Browse files Browse the repository at this point in the history
  • Loading branch information
satouriko committed Sep 17, 2016
1 parent 73d171a commit c0b877a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 11 deletions.
30 changes: 20 additions & 10 deletions ipgw_new/ConfigHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,33 @@ class ConfigHelper
private string appdata;
public ConfigHelper()
{
this.appdata = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
this.CreateDirectory();
//this.appdata = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
//this.CreateDirectory();
//this.appdata += "/2645/ipgw_new";
this.appdata = Environment.CurrentDirectory;
}
private void CreateDirectory()
private bool CreateDirectory()
{
if (!Directory.Exists(appdata + "/2645"))//如果不存在就创建2645文件夹
try
{
Directory.CreateDirectory(appdata + "/2645");
if (!Directory.Exists(appdata + "/2645"))//如果不存在就创建2645文件夹
{
Directory.CreateDirectory(appdata + "/2645");
}
if (!Directory.Exists(appdata + "/2645/ipgw_new"))//如果不存在就创建ipgw_new文件夹
{
Directory.CreateDirectory(appdata + "/2645/ipgw_new");
}
}
if (!Directory.Exists(appdata + "/2645/ipgw_new"))//如果不存在就创建ipgw_new文件夹
catch
{
Directory.CreateDirectory(appdata + "/2645/ipgw_new");
return false;
}
return true;
}
public bool Check()
{
return File.Exists(appdata + "/2645/ipgw_new/ipgw.config");
return File.Exists(appdata + "/ipgw.config");
}
public bool SaveConfig(ipgwConfig myconfig)
{
Expand All @@ -57,7 +67,7 @@ public bool SaveConfig(ipgwConfig myconfig)
xmldoc.AppendChild(root);
try
{
xmldoc.Save(appdata + "/2645/ipgw_new/ipgw.config");
xmldoc.Save(appdata + "/ipgw.config");
}
catch(Exception e)
{
Expand All @@ -69,7 +79,7 @@ public ipgwConfig LoadConfig()
{
XmlDocument xmldoc = new XmlDocument();
ipgwConfig myconfig = new ipgwConfig();
xmldoc.Load(appdata + "/2645/ipgw_new/ipgw.config");
xmldoc.Load(appdata + "/ipgw.config");
XmlNode root = xmldoc.SelectSingleNode(xmldoc.DocumentElement.Name);
myconfig.uid = root.SelectSingleNode("uid").InnerText;
myconfig.pwd = root.SelectSingleNode("pwd").InnerText;
Expand Down
9 changes: 9 additions & 0 deletions ipgw_new/Lib/AutoUpdate.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Program]
Program=ipgw_new
[AutoUpdate]
WName=ipgw
Key=
Switch0=true
Switch1=true
[Version]
Version=2.0.0.0
Binary file added ipgw_new/Lib/StartupHelper.dll
Binary file not shown.
21 changes: 20 additions & 1 deletion ipgw_new/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,36 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using StartupHelper;
using System.Diagnostics;

namespace ipgw_new
{
static class Program
{

static string version = "1.0.0.0";

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
static void Main(string[] args)
{
switch (Startup.start(args, version))
{
case StartupResult.GetVersion:
return;
case StartupResult.LegalLaunch:
break;
case StartupResult.IllegalLaunch:
Process autoUpdate = new Process();
autoUpdate.StartInfo.FileName = "AutoUpdate.exe";
autoUpdate.Start();
autoUpdate.Close();
return;
}

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
Expand Down
6 changes: 6 additions & 0 deletions ipgw_new/ipgw_new.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<ApplicationIcon>ipgw.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="StartupHelper, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Lib\StartupHelper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand Down Expand Up @@ -94,6 +98,7 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Lib\AutoUpdate.ini" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -109,6 +114,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="ipgw.ico" />
<Content Include="Lib\StartupHelper.dll" />
<Content Include="Resources\ipgw.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down

0 comments on commit c0b877a

Please sign in to comment.