[C# - VB] Hướng dẫn khởi động lại chương trình ứng dụng winform
Các bạn sử dụng đoạn script sau để thực hiện khởi động lại ứng dụng của mình:
FULL CODE CSHARP:
private void RestartProgram()
{
// Get file path of current process
var filePath = Assembly.GetExecutingAssembly().Location;
//var filePath = Application.ExecutablePath; // for WinForms
// Start program
Process.Start(filePath);
// For Windows Forms app
Application.Exit();
// For all Windows application but typically for Console app.
//Environment.Exit(0);
}
FULL CODE VISUAL BASIC:
Private Sub RestartProgram()
Dim filePath = Assembly.GetExecutingAssembly().Location
Process.Start(filePath)
Application.[Exit]()
End Sub
Chúc các bạn thành công với thủ thuật đơn giản này.