Update Lib hinzugefügt
This commit is contained in:
21
UpdateLib/Data/UpdateFileInfo.cs
Normal file
21
UpdateLib/Data/UpdateFileInfo.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UpdateLib.Data
|
||||
{
|
||||
[Serializable]
|
||||
public class UpdateFileInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public UpdateFileInfo(string name, string desc)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Description = desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
UpdateLib/Data/UpdateSaveFile.cs
Normal file
34
UpdateLib/Data/UpdateSaveFile.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UpdateLib.Data
|
||||
{
|
||||
[Serializable]
|
||||
public class UpdateSaveFile
|
||||
{
|
||||
public String VersionString { get; set; }
|
||||
public List<UpdateFileInfo> _coll;
|
||||
|
||||
public List<UpdateFileInfo> UpdateFileCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
return _coll;
|
||||
}
|
||||
set
|
||||
{
|
||||
_coll = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public UpdateSaveFile(String version)
|
||||
{
|
||||
this.VersionString = version;
|
||||
UpdateFileCollection = new List<UpdateFileInfo>();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
UpdateLib/Properties/AssemblyInfo.cs
Normal file
36
UpdateLib/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("UpdateLib")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UpdateLib")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
||||
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||
[assembly: Guid("cf95db30-247b-4382-948e-3bd5eb73c938")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
// indem Sie "*" wie unten gezeigt eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
187
UpdateLib/UI/frmUpdater.Designer.cs
generated
Normal file
187
UpdateLib/UI/frmUpdater.Designer.cs
generated
Normal file
@@ -0,0 +1,187 @@
|
||||
namespace UpdateLib.UI
|
||||
{
|
||||
partial class frmUpdater
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.btnInstall = new System.Windows.Forms.Button();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.pbInstall = new System.Windows.Forms.ProgressBar();
|
||||
this.pbDownload = new System.Windows.Forms.ProgressBar();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.lblStatus = new System.Windows.Forms.Label();
|
||||
this.lvItems = new System.Windows.Forms.ListView();
|
||||
this.clmName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.clmStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.clmDesc = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.panel1.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.panel1.Controls.Add(this.btnInstall);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 319);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(472, 49);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// btnInstall
|
||||
//
|
||||
this.btnInstall.Location = new System.Drawing.Point(385, 13);
|
||||
this.btnInstall.Name = "btnInstall";
|
||||
this.btnInstall.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnInstall.TabIndex = 0;
|
||||
this.btnInstall.Text = "Install";
|
||||
this.btnInstall.UseVisualStyleBackColor = true;
|
||||
this.btnInstall.Click += new System.EventHandler(this.btnInstall_Click);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.pbInstall);
|
||||
this.groupBox1.Controls.Add(this.pbDownload);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 235);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(448, 78);
|
||||
this.groupBox1.TabIndex = 1;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Details";
|
||||
//
|
||||
// pbInstall
|
||||
//
|
||||
this.pbInstall.Location = new System.Drawing.Point(120, 45);
|
||||
this.pbInstall.Name = "pbInstall";
|
||||
this.pbInstall.Size = new System.Drawing.Size(322, 23);
|
||||
this.pbInstall.TabIndex = 3;
|
||||
//
|
||||
// pbDownload
|
||||
//
|
||||
this.pbDownload.Location = new System.Drawing.Point(120, 16);
|
||||
this.pbDownload.Name = "pbDownload";
|
||||
this.pbDownload.Size = new System.Drawing.Size(322, 23);
|
||||
this.pbDownload.TabIndex = 2;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(15, 51);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(84, 13);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Install Progress: ";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(15, 21);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(105, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Download Progress: ";
|
||||
//
|
||||
// lblStatus
|
||||
//
|
||||
this.lblStatus.AutoSize = true;
|
||||
this.lblStatus.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblStatus.Location = new System.Drawing.Point(12, 9);
|
||||
this.lblStatus.Name = "lblStatus";
|
||||
this.lblStatus.Size = new System.Drawing.Size(148, 25);
|
||||
this.lblStatus.TabIndex = 2;
|
||||
this.lblStatus.Text = "Status: Waiting...";
|
||||
//
|
||||
// lvItems
|
||||
//
|
||||
this.lvItems.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.clmName,
|
||||
this.clmStatus,
|
||||
this.clmDesc});
|
||||
this.lvItems.Location = new System.Drawing.Point(12, 41);
|
||||
this.lvItems.Name = "lvItems";
|
||||
this.lvItems.Size = new System.Drawing.Size(448, 188);
|
||||
this.lvItems.TabIndex = 3;
|
||||
this.lvItems.UseCompatibleStateImageBehavior = false;
|
||||
this.lvItems.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// clmName
|
||||
//
|
||||
this.clmName.Text = "Name";
|
||||
this.clmName.Width = 104;
|
||||
//
|
||||
// clmStatus
|
||||
//
|
||||
this.clmStatus.Text = "Status";
|
||||
this.clmStatus.Width = 99;
|
||||
//
|
||||
// clmDesc
|
||||
//
|
||||
this.clmDesc.Text = "Description";
|
||||
this.clmDesc.Width = 228;
|
||||
//
|
||||
// frmUpdater
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.ClientSize = new System.Drawing.Size(472, 368);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.lvItems);
|
||||
this.Controls.Add(this.lblStatus);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "frmUpdater";
|
||||
this.Text = "Programm updater";
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Button btnInstall;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.ProgressBar pbInstall;
|
||||
private System.Windows.Forms.ProgressBar pbDownload;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label lblStatus;
|
||||
private System.Windows.Forms.ListView lvItems;
|
||||
private System.Windows.Forms.ColumnHeader clmName;
|
||||
private System.Windows.Forms.ColumnHeader clmStatus;
|
||||
private System.Windows.Forms.ColumnHeader clmDesc;
|
||||
}
|
||||
}
|
||||
107
UpdateLib/UI/frmUpdater.cs
Normal file
107
UpdateLib/UI/frmUpdater.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using UpdateLib.Data;
|
||||
|
||||
namespace UpdateLib.UI
|
||||
{
|
||||
public partial class frmUpdater : Form
|
||||
{
|
||||
int index = 0;
|
||||
private UpdateSaveFile localInfoFile;
|
||||
private String baseUrl;
|
||||
|
||||
public frmUpdater(UpdateSaveFile file, String baseUrl)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
localInfoFile = file;
|
||||
pbInstall.Maximum = (file.UpdateFileCollection.Count) * 100;
|
||||
this.baseUrl = baseUrl;
|
||||
|
||||
foreach (UpdateFileInfo fileInfo in file.UpdateFileCollection)
|
||||
{
|
||||
ListViewItem lvItem = new ListViewItem(new String[] { fileInfo.Name, "Waiting...", fileInfo.Description });
|
||||
lvItems.Items.Add(lvItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnInstall_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (btnInstall.Text.Equals("Finish"))
|
||||
{
|
||||
MessageBox.Show("Update erfolgreich. Programm wird beendet");
|
||||
Application.Exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
btnInstall.Enabled = false;
|
||||
DownloadFile();
|
||||
}
|
||||
}
|
||||
|
||||
private void DownloadFile()
|
||||
{
|
||||
WebClient downloadClient = new WebClient();
|
||||
|
||||
downloadClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(downloadClient_DownloadProgressChanged);
|
||||
downloadClient.DownloadFileCompleted += new AsyncCompletedEventHandler(downloadClient_DownloadFileCompleted);
|
||||
|
||||
ListViewItem currItem = lvItems.Items[index];
|
||||
String name = currItem.SubItems[0].Text;
|
||||
|
||||
SetStatus(String.Format("Downloading {0} ...", name));
|
||||
currItem.SubItems[1].Text = "Downloading...";
|
||||
|
||||
String local = String.Format(@".\{0}", name);
|
||||
String online = String.Format("{0}{1}", baseUrl, name);
|
||||
|
||||
if (File.Exists(local))
|
||||
{
|
||||
if (File.Exists(local + ".old"))
|
||||
File.Delete(local + ".old");
|
||||
File.Move(local, local + ".old");
|
||||
}
|
||||
downloadClient.DownloadFileAsync(new Uri(online), local);
|
||||
}
|
||||
|
||||
private void SetStatus(string p)
|
||||
{
|
||||
lblStatus.Text = String.Format("Status: {0}", p);
|
||||
}
|
||||
|
||||
private void downloadClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
|
||||
{
|
||||
ListViewItem currItem = lvItems.Items[index];
|
||||
currItem.SubItems[1].Text = "Downloaded";
|
||||
|
||||
pbInstall.Increment(100);
|
||||
pbDownload.Value = 0;
|
||||
index++;
|
||||
|
||||
if (lvItems.Items.Count - 1 >= index)
|
||||
DownloadFile();
|
||||
else
|
||||
{
|
||||
SetStatus("Finished!");
|
||||
btnInstall.Text = "Finish";
|
||||
btnInstall.Enabled = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void downloadClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
|
||||
{
|
||||
pbDownload.Value = e.ProgressPercentage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
60
UpdateLib/UpdateLib.csproj
Normal file
60
UpdateLib/UpdateLib.csproj
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{CF95DB30-247B-4382-948E-3BD5EB73C938}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>UpdateLib</RootNamespace>
|
||||
<AssemblyName>UpdateLib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Data\UpdateFileInfo.cs" />
|
||||
<Compile Include="Data\UpdateSaveFile.cs" />
|
||||
<Compile Include="UI\frmUpdater.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\frmUpdater.Designer.cs">
|
||||
<DependentUpon>frmUpdater.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Updater.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
105
UpdateLib/Updater.cs
Normal file
105
UpdateLib/Updater.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using UpdateLib.Data;
|
||||
using UpdateLib.UI;
|
||||
|
||||
namespace UpdateLib
|
||||
{
|
||||
public class Updater : Component
|
||||
{
|
||||
private const String localUpdateFile = @".\UpdateInfo";
|
||||
public String UpdateUrl { get; set; }
|
||||
|
||||
public void CheckForUpdates()
|
||||
{
|
||||
try
|
||||
{
|
||||
CleanUp();
|
||||
WebClient downloadclient = new WebClient();
|
||||
downloadclient.DownloadFile(UpdateUrl, localUpdateFile);
|
||||
downloadclient.Dispose();
|
||||
|
||||
if(!File.Exists(localUpdateFile))
|
||||
{
|
||||
throw new FileNotFoundException("Lokale Update datei ist beschädigt");
|
||||
}
|
||||
|
||||
UpdateSaveFile localFile = DecodeSaveFile(localUpdateFile);
|
||||
|
||||
Version localVersion = Assembly.GetEntryAssembly().GetName().Version;
|
||||
Version onlineVersion = Version.Parse(localFile.VersionString);
|
||||
|
||||
if(onlineVersion > localVersion)
|
||||
{
|
||||
string MsgBox = String.Format("Version {0} verfügbar",onlineVersion);
|
||||
if(MessageBox.Show(MsgBox,"Update",MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
frmUpdater updateform = new frmUpdater(localFile,GetPath(UpdateUrl));
|
||||
updateform.ShowDialog();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(onlineVersion.ToString());
|
||||
MessageBox.Show(localVersion.ToString());
|
||||
MessageBox.Show("Software ist in der aktuellste Version");
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MessageBox.Show("Fehler beim uberprüfen von Updates\nVersuchen Sie später nochmal!\n\nFehlertext: " + e.Message, "Update", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetPath(string UpdateUrl)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String[] updatePieces = UpdateUrl.Split('/');
|
||||
for(int i = 0; i < updatePieces.Length -1; i++)
|
||||
{
|
||||
sb.Append(updatePieces[i] + "/");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private UpdateSaveFile DecodeSaveFile(string localUpdateFile)
|
||||
{
|
||||
FileStream localFileStream = null;
|
||||
BinaryFormatter decoder = null;
|
||||
|
||||
try
|
||||
{
|
||||
localFileStream = File.Open(localUpdateFile, FileMode.Open, FileAccess.Read);
|
||||
decoder = new BinaryFormatter();
|
||||
return (UpdateSaveFile)decoder.Deserialize(localFileStream);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new InvalidDataException("Der lokale updatedatei ist beschädigt "+e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (localFileStream != null)
|
||||
localFileStream.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CleanUp()
|
||||
{
|
||||
DirectoryInfo di = new DirectoryInfo(Application.StartupPath);
|
||||
foreach (FileInfo fi in di.GetFiles("*.old", SearchOption.TopDirectoryOnly))
|
||||
fi.Delete();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user