启动更新程序执行文件

private void button2_Click(object sender, System.EventArgs e)
        
{
            
string updateAppPath = Common.AppStartPath + @"\AutoUpdate.exe";
            
if(!File.Exists(updateAppPath))
            
{
                MessageBox.Show(
"无法找到AutoUpdate应用程序!");
                
return;
            }

            
string argments = Process.GetCurrentProcess().Id.ToString();
            ProcessStartInfo startInfo 
= new ProcessStartInfo(updateAppPath, argments);
            Process updateApp 
= new Process();
            updateApp.StartInfo 
= startInfo;
            updateApp.Start();
        }


得到启动程序的所在的文件夹路径

private static string strAppPath = String.Empty;

        
/// <summary>
        
/// 系统启动路径
        
/// </summary>

        public static string AppStartPath
        
{
            
get
            
{
                
if (strAppPath == String.Empty)
                
{
                    strAppPath 
=
                        System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
                    System.Uri uriPath 
= new Uri(strAppPath);
                    strAppPath 
= uriPath.LocalPath.Replace('/''\\');

                }

                
return strAppPath;
            }

        }


    项目Domo下载:https://files.cnblogs.com/xiaobaigang/test.rar




posted on 2007-11-21 17:50  萧佰刚  阅读(259)  评论(0编辑  收藏  举报