C# 软件升级程序制作
如果做完一个软件后,要进行更新的话,要如何升级程序??
------解决方案--------------------mark
以下是我写的程序很垃圾,参考一下吧。
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using TextAndIni.Ini;
using TextAndIni.Text;
using System.Net;
using System.IO;
using System.Text;
using System.Threading ;
using System.Runtime.InteropServices;
namespace 更新程序
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
[DllImport( "user32.dll ")]
private static extern unsafe IntPtr FindWindow(string lpClassName,string lpWindowName);
[DllImport( "User32.dll ")]
private static extern unsafe int SendMessage(IntPtr hWnd, int Msg,IntPtr wParam,string lParam );
private const int WM_CLOSE = 0x10; //关闭程序。
private string windowName; //主程序窗口名称。
private ArrayList FileList1; //现有文件列表。
private ArrayList FileList2; //下载到的文件列表。
private ArrayList FileSize; //文件大小。
private ArrayList UpdataList; //要更新的文件列表。
private string Hurl; //下载的网址。
private IntPtr Hwnd; //窗口句柄。
private Thread th; //进程1。
private Thread thread; //进程2。
private MyText Textlog;
//*******************************************************************************************
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.StatusBar statusBar1;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
windowName= " ";
string data = string.Format( "{0}年{1}月{2}日 ",DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day);
Textlog = new MyText(Application.StartupPath+ "\\log\\ "+data+ ".log ");
Textlog.WriteText( "**************************************************************************\r\n ");
Textlog.WriteText( "日期: "+DateTime.Now.ToString()+ "程序启动\r\n ");
Textlog.WriteText( "**************************************************************************\r\n ");
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.listView1 = new System.Windows.Forms.ListView();
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//