var fileName = GetPath(_tempFileName);
try
{
File.Delete(fileName);
File.Copy(_args[0], fileName);
if (!File.Exists(fileName))
{
MessageBox.Show("Upgrade Failed, File Not Exist(升级失败,文件不存在).");
return;
}
var startKey = "v2rayN/";
using (ZipArchive archive = ZipFile.OpenRead(fileName))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry.Length == 0)
{
continue;
}
var fullName = entry.FullName;
if (fullName.StartsWith(startKey))
{
fullName = fullName.Substring(startKey.Length, fullName.Length - startKey.Length);
}
string entryOuputPath = GetPath(fullName);
FileInfo fileInfo = new FileInfo(entryOuputPath);
fileInfo.Directory.Create();
entry.ExtractToFile(entryOuputPath, true);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Upgrade Failed(升级失败)." + ex.StackTrace);
return;
}
finally
{
File.Delete(fileName);
}
来源:oschina
链接:https://my.oschina.net/itfanr/blog/3165965