قابلیت آپدیت برنامه

بازدید21.1kپست ها2آخرین فعالیت10 سال پیش
0
0

سلام
یک آموزش ساده برای دوستانی که نیاز دارند برای نرم افزار هایی که می سازند ، قسمت "به روز رسانی" بگذارند :

[CSHARP]
using System.Net;
using System.Net.NetworkInformation;
using System.Diagnostics;
using System.Reflection;
[/CSHARP]

[CSHARP]
namespace Check_For_Update_Softafzar.net
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string Pashmak;
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = "";
label2.Text = "";
label3.Text = "";
linkLabel1.Text = "";

        timer1.Interval = 245;
        timer1.Enabled = true;
    }


    private void timer1_Tick(object sender, EventArgs e)
    {
        progressBar1.PerformStep();
        if (progressBar1.Value == progressBar1.Maximum)
        {
            timer1.Enabled = false;
            if (NetworkInterface.GetIsNetworkAvailable())
            {
                try
                {
                    WebClient webClient = new WebClient();
                    string str1 = webClient.DownloadString("http://localhost/3/index.txt");
                    string str2 = String.Format("{0}", AssemblyVersion); 
                    string strA = str1.Replace(".", "");
                    string strB = str2.Replace(".", "");
                    int i1 = int.Parse(strA);
                    int i2 = int.Parse(strB);
                    if (i1 == i2)
                    {
                        label1.Text = "No New Version";
                        label1.ForeColor = Color.Cyan;
                        label2.Text = "Your Version : " + str2;
                        label3.Text = "Last Version : " + str1;
                    }
                    if (i1 > i2)
                    {
                        label1.Text = "New Version is Released for Download";
                        label1.ForeColor = Color.Lime;
                        label2.Text = "Your Version : " + str2;
                        label3.Text = "Last Version : " + str1;
                        label3.ForeColor = Color.Lime;
                        linkLabel1.Text = "Click For Download new Version";
                        WebClient webClient1 = new WebClient();
                        Pashmak = webClient.DownloadString("http://localhost/3/index2.txt");
                    }
                }
                catch 
                {
                    MessageBox.Show("Check for update was been failed" , "Error"
                                   , MessageBoxButtons.OK, MessageBoxIcon.Error);
                }


            }
            else
            {
                MessageBox.Show("Uh oh , looks like your internet connection is missing !\n" +
                    "Please check your internet connection and try again.",
                    "Internet Connection Error"
                    , MessageBoxButtons.OK, MessageBoxIcon.Error);
                
            }
        }


    }


    public string AssemblyVersion
    {
        get
        {
            return Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }
    }


    private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {
        try
        {
            Process.Start(Pashmak);
        }
        catch { }
    }
}

}

[/CSHARP]

لینکه پروژه پیوست خرابه، از لینکه زیر استفاده کنید

دانلود سورس کد

آخرین ویرایش: 08-04-2014 ???? 21:29، توسط The Arrow
0

mamnoon
va bebakhshid ke poste ghadimi bala avordam
vali kheyli be siurcesh niaz dashtam
age mishe linke source ro update konid
link kharabe
mamnoon

0

لینک دانلود تصحیح شد.

سوال برنامه نویسی دارید؟

ندونستن عیب نیست، نپرسیدن چرا!

خوش آمدید

برای طرح سوال، ایجاد بحث و فعالیت در سایت نیاز است ابتدا وارد حساب کاربری خود شوید. در صورتی که هنوز عضو سایت نیستید میتوانید در عرض تنها چند ثانیه ثبت نام کنید.