c#winform制作安装程序,程序升级问题怎么解决?

解决方案 »

  1.   


    我用vs2005 的ClickOnce 发布方法 可以自动更新!但是 就是没有卸载方式,,,,郁闷的我
    帮忙解决下
      

  2.   

    有没有代码?如果有的话请你给我发一份OK不?先谢谢了我的邮箱是[email protected] 
      

  3.   

    csdn的下载里面好像有,我记得以前看过,lz搜搜吧,这个也不难写的
      

  4.   

    好像不是这样的吧,winform的程序似乎没有办法更新吧,更新之后需要重新安装,是需要重新编译的,更新上去的是无法自动编译的
      

  5.   

    winform 程序只用更新dll就可以完成。建议参考如下例子:http://www.cnblogs.com/glacier/archive/2009/03/27/1423542.html
      

  6.   

    安装包在安装的时候先像注册表里写如软件版本号,当然也可以用ini,config甚至你不怕慢也可以用access.
    然后软件里边要有两个可执行文件,一个是软件本身,另一个更新程序
    然后数据库要有一张表写着最新的软件版本号,软件在启动的时候检查本地版本号和网上的是否一致,不一致的话就启动更新程序,关闭自己,然后通过更新程序来更新软件,更新结束之后再通过更新程序启动新软件
      

  7.   

           #region 更新方法
            public void ProcUpdate()
            {
                updata ws = new updata();
                label1.Text = "联系服务器,检测更新中......";                label1.Text = "联系服务器,检测更新中......";
                    this.Refresh();
                    System.Threading.Thread.Sleep(2000);                label1.Text = "正在获取文件......";                IServer svli = getproxy.getpx();
                    DataTable dt = svli.GetVersion();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string filename = dt.Rows[i]["FileName"].ToString();
                        string Version = dt.Rows[i]["Version"].ToString();                    string url = System.Configuration.ConfigurationSettings.AppSettings["url"].ToString();                    RegistryKey r1 = Registry.CurrentUser;
                        RegistryKey r2 = r1.OpenSubKey("QLSOFT", true);                    switch (filename)
                        {
                            case "clientdb.mdb":                            if (Version != clientdb)
                                {
                                    ws.DownFile("http://" + url + "/Updates" + "/" + "clientdb.mdb", pb); //下载新的更新版本信息替换本地更新版本                                IntFileCount = IntFileCount + 1;                                r2.SetValue("clientdb.mdb", Version);
                                }
                                break;
                            case "Client.exe":
                                if (Version != clientstr)
                                {
                                    ws.DownFile("http://" + url + "/Updates" + "/" + "Client.exe", pb); //下载新的更新版本信息替换本地更新版本                                IntFileCount = IntFileCount + 1;                                r2.SetValue("Client.exe", Version);
                                }
                                break;
                            case "Client.exe.config":
                                if (Version != configstr)
                                {
                                    ws.DownFile("http://" + url + "/Updates" + "/" + "Client.exe.xml", pb); //下载新的更新版本信息替换本地更新版本                                IntFileCount = IntFileCount + 1;                                r2.SetValue("Client.exe.config", Version);
                                }
                                break;
                        }
                        this.Refresh();
                    }
            }
    update.cs
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.IO;
    using System.Net;
    using System.Diagnostics;
    using System.Threading;namespace Updates
    {
        public class updata
        {
            public updata()
            {
                //
                // TODO: 在此处添加构造函数逻辑
                //
            }        //下载服务器文件
            public void DownFile(string Url, System.Windows.Forms.ProgressBar pb)
            {
                HttpWebRequest qingqiu;
                HttpWebResponse xiangying;
                int IntStart = 0;
                int IntLen = 1024;
                int IntRead = 0;
                int intReaded = 0;
                int ContentLen = 0;
                byte[] Buf = new byte[IntLen - 1];
                BinaryReader SR;
                BinaryWriter SW;
                FileStream S;
                //try
                //{
                    string Filename;
                    string StrDir;
                    //Url = Url.ToLower();
                    Url = Url.Replace("\\", "/");
                    Url = Url.Replace("//", "/");
                    Url = Url.Replace(":/", "://");
                    Filename = Url.Substring(Url.LastIndexOf(@"/") + 1);                if (Filename == "clientdb.mdb")
                    {
                        Filename = Application.StartupPath + "\\Data\\clientdb.mdb";                }
                    if (Filename == "Client.exe.config")
                    {
                        Filename = Application.StartupPath + "\\Client.exe.config";                }
                    if (Filename == "Client.exe")
                    {
                        Filename = Application.StartupPath + "\\Client.exe";                }
                    Filename = Filename.Replace("/", "\\");
                    Filename = Filename.Replace("\\\\", "\\");
                    StrDir = Filename.Substring(0, Filename.LastIndexOf("\\"));
                    if (!(Directory.Exists(StrDir)))
                    {
                        Directory.CreateDirectory(StrDir);
                    }
                    qingqiu = (HttpWebRequest)HttpWebRequest.Create(Url);
                    qingqiu.UserAgent = @"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)";
                    qingqiu.CookieContainer = new CookieContainer();
                    xiangying = (HttpWebResponse)qingqiu.GetResponse();
                    ContentLen = (int)xiangying.ContentLength;
                    //MessageBox.Show(ContentLen.ToString());
                    //ContentLen=102400;//
                    pb.Minimum = 0;
                    pb.Maximum = (int)xiangying.ContentLength;
                    S = new FileStream(Filename, FileMode.Create);
                    SR = new BinaryReader(xiangying.GetResponseStream());
                    SW = new BinaryWriter(S);
                    IntRead = SR.Read(Buf, 0, Buf.Length);
                    while (IntRead > 0)
                    {
                        IntStart += IntRead;
                        intReaded += IntRead;
                        pb.Value = intReaded;
                        SW.Write(Buf, 0, IntRead);
                        IntRead = SR.Read(Buf, 0, Buf.Length);
                        Application.DoEvents();
                    }
                    SR.Close();
                    SW.Close();            //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show(ex.Message + Url);
                //}
            }
        }
    }
    代码有删改,思路对吧,放到编辑器里改动一下就可以了
      

  8.   

    支持 
    另外网上有AutoUpdate的例子,你可以看看
      

  9.   

    http://www.cnblogs.com/glacier/archive/2009/03/27/1423542.html