|
public class DelSelf
{
/// <summary>
/// 删除自身,只删除Application对象所取得的文件
/// </summary>
/// <param name="args">删除延时必须大于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 name="args">第一为时间,其他暂无他用</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();
}
}
|
|