先运行UPDATE.EXE的时候先关闭主程序的EXE
不会的.你用一个callback,异步调用啊...先用WEBCLINET类从SERVER上将要下载的文件下载到客户机上,记住不要跟现有的主程序文件名同名,然后等下载完毕后就会执行CALLBACK的过程,这个过程就将原来的主程序文件删除,再将新下回来的改成主程序文件名,并运行它.关闭UPDATE.EXE就可以了.
不会的.你用一个callback,异步调用啊...先用WEBCLINET类从SERVER上将要下载的文件下载到客户机上,记住不要跟现有的主程序文件名同名,然后等下载完毕后就会执行CALLBACK的过程,这个过程就将原来的主程序文件删除,再将新下回来的改成主程序文件名,并运行它.关闭UPDATE.EXE就可以了.
解决方案 »
- 请教个socket的错误问题。
- winfrom 程序 datagridview checkbox 列分页的问题。
- 大家帮我判断一下,这种情况是重载吗?
- Nhibernate一对一情况下,插入如何自己控制顺序
- 求教 关于多线程中生产者与消费者代码解析~ 感谢
- 三层架构中,业务层的含义?
- 怎么添加GridView的CellClick事件(用过Devexpress控件的朋友来帮帮忙)
- 定时触发的问题
- 条件编译的作用域
- 我刚学C#,第一个程序Welcome就不能成功的显示,出现了下面的错误,希望各位大侠进来帮忙谢谢!
- 请问在c#里如何编写结束某个进程的代码
- 400分求购!哪位哥们有一个比较典型的C#(WINFORM)MIS信息系统原代码吗?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Timer1.Enabled = True : Timer1.Interval = 1000 : ProgressBar1.Maximum = 10000 : i = 0
Me.Button1.Visible = False
Dim Pro As New UPgrade1(AddressOf Me.UpGradeFunction)
Dim r As IAsyncResult
'异步调用并显示结果
r = Pro.BeginInvoke(New AsyncCallback(AddressOf ShowResult), Pro)
End Sub
Delegate Sub jg()
Sub ShowResult(ByVal U As IAsyncResult)
Dim rjg As New jg(AddressOf Me.AfterSucces)
Me.Button1.Invoke(rjg)
End Sub
Sub AfterSucces()
Cursor.Current = Cursors.Default
Label1.Text = "下载成功!重新运行程序"
If Not File.Exists(Application.StartupPath & "\test1.exe") Then
MsgBox("下载文件不成功,网络有问题!请重试!", MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly, "提示")
Button1.Visible = True
Label1.Text = ""
Exit Sub
End If
If File.Exists(Application.StartupPath & "\test.exe") Then
File.Delete(Application.StartupPath & "\test.exe")
End If
If File.Exists(Application.StartupPath & "\test1.exe") Then
Rename("test1.exe", "test.exe")
Process.Start(Application.StartupPath & "\test.exe")
End If
Me.Close()
Application.Exit()
End End Sub
Sub UpGradeFunction()
Try
Cursor.Current = Cursors.Hand
Dim Filename As String = "test.exe"
Dim DownUrl As String = "http://" & serverName & "/download/capital/" & Filename
Dim myStringWebResource As String = DownUrl
Dim myWebClient As New WebClient()
myWebClient.DownloadFile(myStringWebResource, Application.StartupPath & "\test1.exe")
myWebClient.Dispose()
Catch ex As Exception
MsgBox(Err.Description & " " & Err.Number, MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "提示")
Cursor.Current = Cursors.Default
Exit Sub
End Try
Cursor.Current = Cursors.Default
End Sub
' Calls this method from the InitializeComponent() method of your form.
Private Sub OtherInitialize()
AddHandler Me.Closing, AddressOf Me.Form1_Cancel
Me.myDataIsSaved = New Boolean()
Me.myDataIsSaved = True
End Sub 'OtherInitializeProtected Sub Form1_Cancel(sender As Object, e As CancelEventArgs)
If Not myDataIsSaved Then
e.Cancel = True
MessageBox.Show("You must save first.")
Else
e.Cancel = False
MessageBox.Show("Goodbye.")
End If
End Sub 'Form1_Cancel
[C#]
// Calls this method from the InitializeComponent() method of your form
private void OtherInitialize() {
this.Closing += new CancelEventHandler(this.Form1_Cancel);
this.myDataIsSaved = new Boolean();
this.myDataIsSaved = true;
}
protected void Form1_Cancel (Object sender, CancelEventArgs e) {
if (!myDataIsSaved) {
e.Cancel = true;
MessageBox.Show("You must save first.");
}
else {
e.Cancel = false;
MessageBox.Show("Goodbye.");
}
}
[C++, JScript] 没有可用于 C++ 或 JScript 的示例。若要查看 Visual Basic 或 C# 示例,请单击页左上角的语言筛选器按钮 。