winJade: C# Check for update - winJade

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

C# Check for update

#1 User is offline   genosyde Icon

  • Member
  • PipPip
  • Group: Member
  • Posts: 48
  • Joined: 25-May 08
  • Gender:Male
  • Location:San Jose CA
  • Interests:Programming, Music, Friends.
  • I'm running:Windows Vista Home Premium/Windows 7

Posted 18 July 2008 - 08:51 AM

Well sense I'm sort of new to this forum i decided ill post a lot and try to get know, so anyway here is some useful code to detect if there is a newer version of the program uploaded to your web server. I'm sure there is an easier way to do it but this is how i do it.


       // For this to work you must name your files correctly
       int version = 1; //<---Version Number
       int nextVersion = version + 1;

        private void Form1_Load(object sender, EventArgs e)
        {
            //Checks your site for your file and sees if it exists
            Uri urlCheck = new Uri("http://www.YourSiteHere/Downloads/MyAppVersion" + nextVersion + ".zip");
            WebRequest request = WebRequest.Create(urlCheck);
            request.Timeout = 15000;
            WebResponse response;
            try
            {
                response = request.GetResponse();
                MessageBox.Show("There is a newer version of this product would you like to download it?");
            }
            catch (Exception)
            {
             // This is if the file doesnt exist
             // MessageBox.Show("No new updates.");
            }
         }


I hope you guys like it.
I also hope i explained it good enough. :D

See ya.
foreach(spam s in inbox)
{
	  s.GTFO;
}
0

#2 User is offline   Edootjuh Icon

  • WARNING, may contain nuts!
  • PipPipPipPipPip
  • Group: Forum Guru
  • Posts: 2,756
  • Joined: 24-December 05
  • Gender:Male
  • Location:The Netherlands
  • I'm running:the latest Windows 7 build, probably.

Posted 18 July 2008 - 10:15 AM

I wouldn't do it like that.
I'd have a text file on the webserver with the latest version in it (just the number), and the download link.
Then I'd have my application check if the number is higher than the currently installed version, and if so, download the new version.

VB.net:
Imports System.IO
Imports System.Net

Public Class Form1
	Dim CurrentVersion As Integer = 254
	Private Sub CheckForUpdates()
		Dim request As WebRequest = WebRequest.Create("http://localhost/version.txt")
		Dim response As WebResponse = request.GetResponse()
		Dim reader As New StreamReader(response.GetResponseStream())
		Dim NewestVersion As Integer = reader.ReadLine()
		Dim Link As String = reader.ReadLine()
		If NewestVersion > CurrentVersion Then
			MessageBox.Show("A newer version is available: " & NewestVersion & vbNewLine & Link)
		End If
	End Sub

	Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		CheckForUpdates()
	End Sub
End Class


C# converted (http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx):
using System.IO;
using System.Net;

public class Form1
{
	int CurrentVersion = 254;
	private void CheckForUpdates()
	{
		WebRequest request = WebRequest.Create("http://localhost/version.txt");
		WebResponse response = request.GetResponse();
		StreamReader reader = new StreamReader(response.GetResponseStream());
		int NewestVersion = reader.ReadLine();
		string Link = reader.ReadLine();
		if (NewestVersion > CurrentVersion) {
			MessageBox.Show("A newer version is available: " + NewestVersion + Constants.vbNewLine + Link);
		}
	}
	
	private void Form1_Load(object sender, System.EventArgs e)
	{
		CheckForUpdates();
	}
}


EDIT: Oh right, and this is the version.txt file:
263
http://localhost/someapp.exe

Posted Image
0

#3 User is offline   genosyde Icon

  • Member
  • PipPip
  • Group: Member
  • Posts: 48
  • Joined: 25-May 08
  • Gender:Male
  • Location:San Jose CA
  • Interests:Programming, Music, Friends.
  • I'm running:Windows Vista Home Premium/Windows 7

Posted 18 July 2008 - 09:57 PM

Oh that way seems easier, thanks i couldn't get it to read a text file from a web server before.
Thanks.

P.S for anyone else, feel free to post how you check too.
foreach(spam s in inbox)
{
	  s.GTFO;
}
0

#4 User is offline   genosyde Icon

  • Member
  • PipPip
  • Group: Member
  • Posts: 48
  • Joined: 25-May 08
  • Gender:Male
  • Location:San Jose CA
  • Interests:Programming, Music, Friends.
  • I'm running:Windows Vista Home Premium/Windows 7

Posted 18 July 2008 - 09:58 PM

Oh that way seems easier, thanks i couldn't get it to read a text file from a web server before.
Thanks.

P.S for anyone else, feel free to post how you check too.

EDIT: Can a mod delete this reply please, i accidentally pressed submit twice
foreach(spam s in inbox)
{
	  s.GTFO;
}
0

#5 User is offline   Tierro Icon

  • DO
  • PipPipPipPipPip
  • Group: Forum Guru
  • Posts: 1,051
  • Joined: 22-February 07
  • Gender:Male
  • Location:PRINT "ROB IS AWESOME"
  • Interests:SLEEP 1
  • I'm running:LOOP

Posted 19 July 2008 - 07:35 AM

View PostEdootjuh, on Jul 18 2008, 12:15 PM, said:

I wouldn't do it like that.
I'd have a text file on the webserver with the latest version in it (just the number), and the download link.
Then I'd have my application check if the number is higher than the currently installed version, and if so, download the new version.

/code snippets/


Good job edo - does this work? :P (Not feeling like giving it a mental-debug atm.)
0

#6 User is offline   Edootjuh Icon

  • WARNING, may contain nuts!
  • PipPipPipPipPip
  • Group: Forum Guru
  • Posts: 2,756
  • Joined: 24-December 05
  • Gender:Male
  • Location:The Netherlands
  • I'm running:the latest Windows 7 build, probably.

Posted 19 July 2008 - 07:49 AM

yup, it works :P
Posted Image
0

#7 User is offline   Sevan Icon

  • Forum Guru
  • PipPipPipPipPip
  • Group: Forum Guru
  • Posts: 561
  • Joined: 13-May 07
  • Gender:Male
  • Location:York, Pennsylvania
  • Interests:Computers, Computer Programming (Software Development), Writing, Music Production, and Photography
  • I'm running:Windows 7

Posted 26 July 2008 - 10:55 PM

Fancy.. I might try that.
Posted Image
0

#8 User is offline   megha Icon

  • Newbie
  • Pip
  • Group: Member
  • Posts: 2
  • Joined: 03-March 09

Posted 03 March 2009 - 07:04 PM

I am doing a project on networking which includes a module of update checker(Language:c#). I finished collecting list of softwares installed on a system, but yet to get the latest version(available) for those softwares from internet. Have heard of so many such update checkers like updatestar,sumo,secunia psi,filehippo,but unable to find logic behind them. Can anyone give some suggestions on how to track the updates available for a list of softwares from web...glanced through this piece of code, thought it would help me...what all modifications should be done to the code to suit my requirement??? :) ...Expecting reply soon :)
0

#9 User is offline   Tierro Icon

  • DO
  • PipPipPipPipPip
  • Group: Forum Guru
  • Posts: 1,051
  • Joined: 22-February 07
  • Gender:Male
  • Location:PRINT "ROB IS AWESOME"
  • Interests:SLEEP 1
  • I'm running:LOOP

Posted 04 March 2009 - 07:16 AM

View Postmegha, on Mar 3 2009, 08:04 PM, said:

I am doing a project on networking which includes a module of update checker(Language:c#). I finished collecting list of softwares installed on a system, but yet to get the latest version(available) for those softwares from internet. Have heard of so many such update checkers like updatestar,sumo,secunia psi,filehippo,but unable to find logic behind them. Can anyone give some suggestions on how to track the updates available for a list of softwares from web...glanced through this piece of code, thought it would help me...what all modifications should be done to the code to suit my requirement??? :) ...Expecting reply soon :)


Here's your reply you were expecting soon,

Isn't the second piece of code just right already?
What do you want it to do else?
0

#10 User is offline   megha Icon

  • Newbie
  • Pip
  • Group: Member
  • Posts: 2
  • Joined: 03-March 09

Posted 07 March 2009 - 05:47 PM

View PostTierro, on Mar 4 2009, 08:16 AM, said:

View Postmegha, on Mar 3 2009, 08:04 PM, said:

I am doing a project on networking which includes a module of update checker(Language:c#). I finished collecting list of softwares installed on a system, but yet to get the latest version(available) for those softwares from internet. Have heard of so many such update checkers like updatestar,sumo,secunia psi,filehippo,but unable to find logic behind them. Can anyone give some suggestions on how to track the updates available for a list of softwares from web...glanced through this piece of code, thought it would help me...what all modifications should be done to the code to suit my requirement??? :) ...Expecting reply soon :)


Here's your reply you were expecting soon,

Isn't the second piece of code just right already?
What do you want it to do else?


The thing is... i need to know the website of each & every piece of software for tracking its latest versions (as inferred from first two codes). How to do it in a generalized way? I thought of using rss feeds...how about this idea? Will the results be genuine? is there any other ways?
0

#11 User is offline   Ola Icon

  • Member
  • PipPip
  • Group: Member
  • Posts: 10
  • Joined: 09-March 09

Posted 09 March 2009 - 05:02 PM

I developed a dotNet application in C# and compile it using innosetup for deployment and distribution. How can I make it possible for application to check for update ??

Thanks for reply in advance.
0

#12 User is offline   Sevan Icon

  • Forum Guru
  • PipPipPipPipPip
  • Group: Forum Guru
  • Posts: 561
  • Joined: 13-May 07
  • Gender:Male
  • Location:York, Pennsylvania
  • Interests:Computers, Computer Programming (Software Development), Writing, Music Production, and Photography
  • I'm running:Windows 7

Posted 09 March 2009 - 06:35 PM

Are we talking application updates or file updates?

Either way, there is a feature built into the Express Products, as well as Visual Studio called ClickOnce Deployment. You deploy the application in a .application format, of which the application runs off of. You can put it on a FrontPage Extension supported Web Server. More on this here.
Posted Image
0

#13 User is offline   Ola Icon

  • Member
  • PipPip
  • Group: Member
  • Posts: 10
  • Joined: 09-March 09

Posted 10 March 2009 - 12:04 AM

View PostSevan, on Mar 9 2009, 07:35 PM, said:

Are we talking application updates or file updates?

Either way, there is a feature built into the Express Products, as well as Visual Studio called ClickOnce Deployment. You deploy the application in a .application format, of which the application runs off of. You can put it on a FrontPage Extension supported Web Server. More on this here.


Hello,

I am asking about application update. I don't want to use clickonce.
0

#14 User is offline   Ola Icon

  • Member
  • PipPip
  • Group: Member
  • Posts: 10
  • Joined: 09-March 09

Posted 10 March 2009 - 12:07 AM

Error on ur codes.
0

#15 User is offline   peacho Icon

  • Houston, we have 2,000.
  • PipPipPipPipPip
  • Group: Expert
  • Posts: 2,208
  • Joined: 19-May 06
  • Gender:Male
  • Interests:Technology, perusing the Internet, Weather, web design
  • I'm running:XP Pro SP3, Windows 7 RC

Posted 10 March 2009 - 12:53 AM

View PostOla, on Mar 9 2009, 08:04 PM, said:

View PostSevan, on Mar 9 2009, 07:35 PM, said:

Are we talking application updates or file updates?

Either way, there is a feature built into the Express Products, as well as Visual Studio called ClickOnce Deployment. You deploy the application in a .application format, of which the application runs off of. You can put it on a FrontPage Extension supported Web Server. More on this here.


Hello,

I am asking about application update. I don't want to use clickonce.

You can use ClickOnce to do easy application updates. Don't know if that mattersr to you, but I thought I'd mention it in case you didn't realize that.
0

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users