StableVersion4.3/AppAutoUpdater/AutoUpdater/AutoUpdateHelper/CommonUnitity.cs

57 lines
1.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*****************************************************************
* Copyright (C) Knights Warrior Corporation. All rights reserved.
*
* Author: 圣殿骑士Knights Warrior
* Email: KnightsWarrior@msn.com
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
* Create Date: 5/8/2010
* Usage:
*
* RevisionHistory
* Date Author Description
*
*****************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
namespace KnightsWarriorAutoupdater
{
class CommonUnitity
{
public static string SystemBinUrl = AppDomain.CurrentDomain.BaseDirectory;
public static void RestartApplication()
{
Process.Start(Application.ExecutablePath);
Environment.Exit(0);
}
public static string GetFolderUrl(DownloadFileInfo file)
{
string folderPathUrl = string.Empty;
int folderPathPoint = file.DownloadUrl.IndexOf("/", 15) + 1;
string filepathstring = file.DownloadUrl.Substring(folderPathPoint);
int folderPathPoint1 = filepathstring.IndexOf("/");
string filepathstring1 = filepathstring.Substring(folderPathPoint1 + 1);
if (filepathstring1.IndexOf("/") != -1)
{
string[] ExeGroup = filepathstring1.Split('/');
for (int i = 0; i < ExeGroup.Length - 1; i++)
{
folderPathUrl += "\\" + ExeGroup[i];
}
if (!Directory.Exists(SystemBinUrl + ConstFile.TEMPFOLDERNAME + folderPathUrl))
{
Directory.CreateDirectory(SystemBinUrl + ConstFile.TEMPFOLDERNAME + folderPathUrl);
}
}
return folderPathUrl;
}
}
}