It may be used under the terms of the GNU General Public License. */\r
\r
using System;\r
-using System.Collections.Generic;\r
-using System.ComponentModel;\r
-using System.Data;\r
-using System.Drawing;\r
-using System.Text;\r
using System.Windows.Forms;\r
using System.Net;\r
using System.IO;\r
{\r
public partial class frmDownload : Form\r
{\r
- private Thread downloadThread;\r
+ private readonly Thread downloadThread;\r
private Stream responceStream;\r
private Stream loacalStream;\r
private HttpWebRequest webRequest;\r
private delegate void DownloadCompleteCallback();\r
private delegate void DownloadFailedCallback();\r
\r
+ private string file;\r
\r
- public frmDownload()\r
+ public frmDownload(string filename)\r
{\r
InitializeComponent();\r
\r
+ file = filename;\r
downloadThread = new Thread(Download);\r
downloadThread.Start();\r
}\r
\r
private void Download()\r
{\r
- Functions.AppcastReader rssRead = new Functions.AppcastReader();\r
string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe");\r
- string hbUpdate = rssRead.downloadFile();\r
+ string hbUpdate = file;\r
WebClient wcDownload = new WebClient();\r
\r
try\r
responceStream = wcDownload.OpenRead(hbUpdate);\r
loacalStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.None);\r
\r
- int bytesSize = 0;\r
+ int bytesSize;\r
byte[] downBuffer = new byte[2048];\r
\r
long flength = 0;\r
{\r
loacalStream.Write(downBuffer, 0, bytesSize);\r
flength = loacalStream.Length;\r
- this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize });\r
+ Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize });\r
}\r
\r
responceStream.Close();\r
loacalStream.Close();\r
\r
if (flength != fileSize)\r
- this.Invoke(new DownloadFailedCallback(this.downloadFailed));\r
+ Invoke(new DownloadFailedCallback(this.downloadFailed));\r
else\r
- this.Invoke(new DownloadCompleteCallback(this.downloadComplete));\r
+ Invoke(new DownloadCompleteCallback(this.downloadComplete));\r
}\r
catch (Exception)\r
{\r
}\r
catch (Exception exc)\r
{\r
- MessageBox.Show("Integer Convertion Error On Download \n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ MessageBox.Show("Integer Conversion Error On Download \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
}\r
\r
btn_cancel.Text = "Close";\r
\r
string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe");\r
-\r
- Process startInstall = Process.Start(tempPath);\r
+ Process.Start(tempPath);\r
this.Close();\r
Application.Exit();\r
}\r