Re: Program Launcher Help
can you clearly break up your problem in to smaller ones ?
Also where are you creating the worker thread Update in your code ?
Re: Program Launcher Help
well to break it down the best I can. The progress bar Wont Work, the program isn't sending out to check the program version like it should, and the patching system ain't working. So basically anything that has to do with reaching out for internet files wont work.
Also i'm not sure what you mean by update thread. The main patching system is done with ICSharpCode SharpZip which is suppose to look for the zip file in my server, downloads it, and then extracts it, overriding the old files, but it ain't working at all. Then the Progress Bar is suppose to work alo0ng side the patching. Then the version this is what is the trigger. What its suppose to do is look for a file on my server (http://www.divineshadowsonline.com/game/version.txt) and then checks it with the file versions within the program and if the files are older, it then activates the patching tool to get the files. but none of it is working at all.
Re: Program Launcher Help
I've made a few adjustments to the code above so here is the updated code. Its still don't work, but its been formatted better this time.
Code:
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
using System.Net;
using System.Text;
namespace Divine_Shadows
{
public partial class DSL : Form
{
public DSL()
{
InitializeComponent();
}
private void DSL_Load(object sender, System.EventArgs e)
{
WebClient update = new WebClient();
decimal Version = 0.1m;
decimal Online = 0.1m;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.divineshadowsonline.com/game/version.txt");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252));
Online = Convert.ToDecimal(sr.ReadToEnd());
if (Version >= Online)
{
File_Progress_Title.Text = "100%";
Total_Progress_Title.Text = "100%";
VersionOld.Visible = false;
VersionNew.Visible = true;
}
else
{
VersionNew.Visible = false;
VersionOld.Visible = true;
update.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback);
update.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadCompleted);
Update_Status.Text = "Updating...";
while (update.IsBusy)
{
Application.DoEvents();
}
update.DownloadFileAsync(new Uri("http://www.divineshadowsonline.com/game/updates/patch.zip"), @"C:\patch.zip");
}
}
public void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e)
{
File_Progress_Display.Value = e.ProgressPercentage;
File_Progress_Title.Text = Convert.ToString(e.ProgressPercentage) + "%";
}
public void DownloadCompleted(Object sender, AsyncCompletedEventArgs e)
{
FastZip zip = new FastZip();
zip.ExtractZip(@"C:\patch.zip", Application.StartupPath.ToString(), @"C:\Program Files\Divine Shadows\");
}
private void Cancel_Click(object sender, EventArgs e)
{
Close();
}
private void Register_Click(object sender, EventArgs e)
{
Process.Start("http://www.divineshadowsonline.com/register.php");
}
private void Play_Click(object sender, EventArgs e)
{
Process.Start("Game.exe");
}
private void Minimize_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
private void Help_Click(object sender, EventArgs e)
{
Process.Start("http://www.divineshadowsonline.com/faq.php");
}
private void Forum_Click(object sender, EventArgs e)
{
Process.Start("http://www.forum.divineshadowsonline.com");
}
private void WSite_Click(object sender, EventArgs e)
{
Process.Start("http://www.divineshadowsonline.com");
}
private void SAILogo_Click(object sender, EventArgs e)
{
Process.Start("http://www.shiningashes.net");
}
}
}
Re: Program Launcher Help
where are the following things declared in your code ?
File_Progress_Title.Text = "100%";
Total_Progress_Title.Text = "100%";
VersionOld.Visible = false;
VersionNew.Visible = true;
File_Progress_Display.Value = e.ProgressPercentage;
Re: Program Launcher Help
that all are names assigned to labels, which are part of the design code. But I found out my problem was that the DSL_Load didn't get called in the design files, so I got that working, but here is the new code I have working:
Code:
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
using System.Net;
using System.Text;
namespace Divine_Shadows
{
public partial class DSL : Form
{
public DSL()
{
this.InitializeComponent();
}
public WebClient update = new WebClient();
public FastZip zip = new FastZip();
private void DSL_Load(object sender, EventArgs e)
{
decimal Version = 0.1m;
decimal Online = 0.1m;
string vernumber = "ver. 1.0";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.divineshadowsonline.com/game/version.txt");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252));
Online = Convert.ToDecimal(sr.ReadToEnd());
if (Version >= Online)
{
this.File_Progress_Title.Text = "100%";
this.Total_Progress_Title.Text = "100%";
this.VersionOld.Visible = false;
this.VersionNew.Visible = true;
this.VersionNew.Text = vernumber;
}
else
{
this.VersionNew.Visible = false;
this.VersionOld.Visible = true;
this.VersionOld.Text = vernumber;
Update_Status.Text = "Checking For Updates...";
update.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgress);
update.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadCompleted);
while (update.IsBusy)
{
Application.DoEvents();
}
update.DownloadFileAsync(new Uri("http://www.divineshadowsonline.com/game/updates/patch.zip"), @"C:\Program Files\Divine Shadows\patch.zip");
}
}
public void DownloadProgress(object sender, DownloadProgressChangedEventArgs e)
{
File_Progress_Display.Value = e.ProgressPercentage;
File_Progress_Title.Text = Convert.ToString(e.ProgressPercentage) + "%";
Total_Progress_Display.Value = e.ProgressPercentage;
Total_Progress_Title.Text = Convert.ToString(e.ProgressPercentage) + "%";
Update_Status.Text = "Downloading...";
}
public void DownloadCompleted(Object sender, AsyncCompletedEventArgs e)
{
zip.ExtractZip(@"C:\Program Files\Divine Shadows\patch.zip", Application.StartupPath.ToString(), @"C:\Program Files\Divine Shadows");
Update_Status.Text = "Installing Patch...";
}
private void Cancel_Click(object sender, EventArgs e)
{
Close();
}
private void Register_Click(object sender, EventArgs e)
{
Process.Start("http://www.divineshadowsonline.com/register.php");
}
private void Play_Click(object sender, EventArgs e)
{
Process.Start("Game.exe");
}
private void Minimize_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
private void Help_Click(object sender, EventArgs e)
{
Process.Start("http://www.divineshadowsonline.com/faq.php");
}
private void Forum_Click(object sender, EventArgs e)
{
Process.Start("http://www.forum.divineshadowsonline.com");
}
private void WSite_Click(object sender, EventArgs e)
{
Process.Start("http://www.divineshadowsonline.com");
}
private void SAILogo_Click(object sender, EventArgs e)
{
Process.Start("http://www.shiningashes.net");
}
}
}
The problem is it finds the fine and downloads it to the right place, but it doesn't extract it. And since I got the main idea from another code, i'm not sure if i'm going things right, but here are the lines related to finding the file, downloading it and are suppose to extract the file.
Code:
update.DownloadFileAsync(new Uri("http://www.divineshadowsonline.com/game/updates/patch.zip"), @"C:\Program Files\Divine Shadows\patch.zip");
and
Code:
zip.ExtractZip(@"C:\Program Files\Divine Shadows\patch.zip", Application.StartupPath.ToString(), @"C:\Program Files\Divine Shadows");
but if the last one keep causing the error after the file fully downloads, so i'm sure its the problem.
Re: Program Launcher Help
so you mean to say private void DSL_Load(object sender, EventArgs e) was not getting called?
what did you change in your designer file to get it work ?
Re: Program Launcher Help
I just needed to add this:
Code:
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DSL));
Re: Program Launcher Help
Re: Program Launcher Help
yea but i still have a problem or two here and there, but at least its downloading the patch now, i just need to figure out why it wont extract the file to where I want it extracted to.... Then I need to figure out how to get one progress bar to track the files download and then have the other track the files extraction process....
Re: Program Launcher Help
If it is problem with Zipping/Unzipping then you need to check out with the code related to that.
For the progress Bar display you need to attach that control to one of the form and set the visible field to true.
Re: Program Launcher Help
well I got the bars in place, umm this might help some to give you an idea what i want done with the bars:
http://i25.photobucket.com/albums/c5...aunchPanel.png
The top one will check the downloading progress and the other will tell the unzipping progress. I got the downloading process to work, but the part of the code that does the unzipping progress wont let me setup a progress bar in it without causing an error.
Re: Program Launcher Help
Quote:
Originally Posted by
dog199200
I got the downloading process to work, but the part of the code that does the unzipping progress wont let me setup a progress bar in it without causing an error.
show the source code you have tried and what specific error is it showing ?
Re: Program Launcher Help
well for the over all source code i'm using ICSharpCode.SharpZipLib.Zip as a reference which is a C# compiling core system. This is what is suppose to extract the files:
Code:
public void DownloadCompleted(Object sender, AsyncCompletedEventArgs e)
{
zip.ExtractZip("patch.zip", Application.StartupPath.ToString(), @"C:\");
Update_Status.Text = "Installing Patch...";
}
to be exact its:
Code:
zip.ExtractZip("patch.zip", Application.StartupPath.ToString(), @"C:\");
but I have no idea what to really use. When i found the code it looked like this:
Code:
zip.ExtractZip("", Application.StartupPath.ToString(), "");
so I assumed the first set fo "s is the file and the second is either the files location of the extraction location, but neither work, all I know is if you don't end the last one with a trailing slash it screws up the Application.Run(new DSL()); function under the Program file.
Re: Program Launcher Help
Is ICSharpCode.SharpZipLib.Zip is a library or dll ?
Do you have the source code for it ?
what is the return type of Zip.ExtractZip(....) function ?
Why dont you check the return type of it and see was the function successfull or not ?
If you have the source code then try to put break point and trace it through as to why this Zip function is failing