I'd like my .NET Compact Framework app to delete itself after it finishes executing. What's the best way to do this?
On a Windows machine it's possible to do this using a .bat file, but that's not an option on mobile devices.
I'd like my .NET Compact Framework app to delete itself after it finishes executing. What's the best way to do this?
On a Windows machine it's possible to do this using a .bat file, but that's not an option on mobile devices.
One idea is you could use wceload:
http://msdn.microsoft.com/en-us/library/bb158700.aspx
Write a cab file that has a custom step (I think you might need to create a setup.dll) that will delete your application.
Get your application to call wceload when it exits to run this cab, passing the argument for wce load to delete the cab after it's finished running.
Not very slick I know.
Write your own deleter.exe program and run that to delete your main exe, but you'd have to leave that behind on the device... unless your device has a ram drive you could run deleter.exe from, so that it would disappear on reboot.
In Windows Mobile there is the directory:
\application data\volatile
This directory is kept for as long as the device has power.
So what we do is:
For compatiblity with all devices you should use the "SHGetSpecialFolderPath" function with CSIDL_APPDATA to get the application data directory and append "\volatile" to it.