How to delete my windows application app.exe in program files on uninstalling in c#....On uninstalling my exe its not getting removed from program files...I gave the administrative rts as follows for my app.exe...Also under which event i should write the code to do so...
Collapse | Copy Code
`

Inline Code Example HereProcessStartInfo proc = new ProcessStartInfo();
proc.UseShellExecute = true;
proc.FileName = Application.ExecutablePath;
proc.Verb = "runas";



try
            {

                Process.Start(proc);

            }

            catch

            {

                // The user refused the elevation.

                // Do nothing and return directly ...

                return;

            }

            Application.Exit();  // Q

`

and also added app.manifest with requireadministrator option...Still its not going from program files on uninstalling...

A program can't delete itself because it's currently running. You need to create a Windows Scheduled task to delete the file on the next boot up/shut down.

You need to P/Invoke MoveFileEx which will mark the file/folder for deletion upon the next boot up.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.