args[0])) { UseShellExecute=true

时间:2021-09-14 06:34:33

运行完毕后删除本身:

public class DelSelf
    {
        /// <summary>
        /// 删除自身,只删除Application东西所取得的文件
        /// </summary>
        /// <param>删除延时必需大于0,也不需太长,太小可能导致删不失!请按照计算机性能自行调解</param>
        public void Delself(params int[]args)
        {
           
           
            ProcessStartInfo psi = (args.Length<=0)?new ProcessStartInfo("cmd.exe","/C choice /C Y /N /D Y /T 3 & Del "+Application.ExecutablePath):new ProcessStartInfo("cmd.exe",string.Format("/C choice /C Y /N /D Y /T {0} & Del "+Application.ExecutablePath,args[0]))
            {
                UseShellExecute=true,
                WindowStyle=ProcessWindowStyle.Hidden,
                CreateNoWindow=true,
               
        };
            Process.Start(psi);
            Application.Exit();
        }
        /// <summary>
        /// 删除自身,删除自身地址目录下的所有文件!
        /// </summary>
        /// <param>第一为时间,其他暂无他用</param>
        public void DelselfDir(params int []args)
        {

ProcessStartInfo psi = (args.Length<=0) ?new ProcessStartInfo("cmd.exe","/C choice /C Y /N /D Y /T 3 & Del "+Application.StartupPath) : new ProcessStartInfo("cmd.exe",string.Format("/C choice /C Y /N /D Y /T {0} & Del "+Application.StartupPath,args[0]))
            {
                UseShellExecute=true,
                WindowStyle=ProcessWindowStyle.Hidden,
                CreateNoWindow=true,
            };
            Process.Start(psi);
            Application.Exit();
        }
    }