Force Deleting Files + Replacing Files (Help)

Hi Everybody there
I'm Having a probleme whit coping files or deleting them
For exemple i want to delete a file in program file

For Deleting Files I Have That problem when i Use:

Kill(Target File)

But the problem is like that (Info: the program is not running):

Quote

Access to the path 'C:\Program Files\Apple Software Update\SoftwareUpdate.exe' is denied.

The Seconde problem thant when i want to copy a file to a directory that the file exist
it gave to me a chose to replace or copy file whit other name ..
I want copying fil and replacing a without showing any message

Re: Force Deleting Files + Replacing Files (Help)

Posted 06 January 2011 - 04:02 PM

Yeah. The kill command won't force delete (regardless of permissions). The user will need to run your application as administrator, and then you'll have to perform a delete on reboot to make absolutely sure a file/folder is deleted regardless of permissions. Even then, most anti viruses will have some sort of low level protection in the kernel against that kind of thing.

You can get windows to delete files on reboot from the registry (take a look at this, scroll down to the bottom for solution, ignore the subscribe thingy.)

Re: Force Deleting Files + Replacing Files (Help)

Posted 06 January 2011 - 05:06 PM

You will need to wait for the process to release the file before being able to overwrite it. To copy without prompt either delete the file that exists in the destination directory or run a bat using xcopy and the correct switches. They can be found on msdn.

Re: Force Deleting Files + Replacing Files (Help)

Posted 06 January 2011 - 05:51 PM

xnn, on 06 January 2011 - 04:06 PM, said:

You will need to wait for the process to release the file before being able to overwrite it. To copy without prompt either delete the file that exists in the destination directory or run a bat using xcopy and the correct switches. They can be found on msdn.