123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.Configuration;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Windows.Forms;
- using Update.Util;
- namespace Update.Config
- {
-
-
-
- public static class HostConfig
- {
- private static string m_DownLoadURL;
- public static string DownLoadURL
- {
- get
- {
- if(m_DownLoadURL==null)
- m_DownLoadURL= HttpUtils.GetDownloadUrl(Const.Key);
- return m_DownLoadURL;
- }
- }
- private static string m_ExecutablePath;
-
-
-
- public static string ExecutablePath
- {
- get { return m_ExecutablePath; }
- }
-
- private static string m_ExecutableDirectory;
-
-
-
- public static string ExecutableDirectory
- {
- get
- {
- return m_ExecutableDirectory ?? (m_ExecutableDirectory = FilePathUtil.GetDirectoryName(ExecutablePath));
- }
- }
- private static string m_ExecutableName;
-
-
-
- public static string ExecutableName
- {
- get { return m_ExecutableName ?? (m_ExecutableName = Path.GetFileName(ExecutablePath)); }
- }
- private static Version m_CurrentVersion;
-
-
-
- public static Version CurrentVersion
- {
- get
- {
- if (m_CurrentVersion == null)
- {
-
-
-
- var dirPath = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
- string copyDestPath = Path.Combine(dirPath, ExecutableName);
-
- try
- {
- File.Copy(ExecutablePath, copyDestPath, true);
- }
- catch (Exception e)
- {
-
- }
-
- if (File.Exists(copyDestPath))
- m_CurrentVersion = Assembly.ReflectionOnlyLoadFrom(copyDestPath).GetName().Version;
- }
- return m_CurrentVersion;
- }
- }
-
-
-
-
- public static void Init(string executablePath)
- {
- m_ExecutablePath = executablePath;
- m_ExecutableDirectory = null;
- m_ExecutableName = null;
- m_CurrentVersion = null;
- }
-
-
-
- public static void RefreshVersion()
- {
- m_CurrentVersion = null;
- }
- }
- }
|