How can I mark the file for deletion upon next reboot?
class Program
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern bool MoveFileEx(string
lpExistingFileName, string lpNewFileName, int dwFlags);
public const int MOVEFILE_DELAY_UNTIL_REBOOT = 0x4;
public static void DeleteOnReboot(string filename)
{
if (!MoveFileEx(filename, null,
MOVEFILE_DELAY_UNTIL_REBOOT))
System.Windows.Forms.MessageBox.Show("Failed");
}
static void Main(string[] args)
{
DeleteOnReboot(@"C:\test.txt");
}
}