Custom Uninstall not deleting file in .net Application












0















I have a settings file created when user run the wpf application.
I have created a custom uninstaller to delete some registry keys related to my app and to delete this setting file.
But my file is not getting deleted.
Here is the code -



 public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);

try
{
using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true))
{

if (registryKey.GetValue("TeachingManagementTool") != null)
{
registryKey.DeleteValue("TeachingManagementTool", true);
}
}
if (File.Exists("Setting.ini"))
File.Delete("Setting.ini");
}
catch (Exception ex)
{
MessageBox.Show("Registry Keys exception " + ex.Message);
}

}


I tried Directory.GetCurrentDirectory() to get file names and delte it, but it doesnt work. So I checked this line of code works file.Delete(filename). It delets the specified file. So it should delete the file during uninstall as its in the same folder.



At the end I should say- I tried 2-3 different ways to access that file and delete it during uninstallation. but Its not delteting and throwing error some times and sometimes no exception at all.




The exception was related to Access to SysWOW64AdvanceInstaller is
denied




FYI - MY App has <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> already.



I tried solutions available on StackOverflow but its not working So I needed to ask a new question. So please let me know where I am mistaking. I am sure it is something very minor that I might be missing here










share|improve this question





























    0















    I have a settings file created when user run the wpf application.
    I have created a custom uninstaller to delete some registry keys related to my app and to delete this setting file.
    But my file is not getting deleted.
    Here is the code -



     public override void Uninstall(IDictionary savedState)
    {
    base.Uninstall(savedState);

    try
    {
    using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true))
    {

    if (registryKey.GetValue("TeachingManagementTool") != null)
    {
    registryKey.DeleteValue("TeachingManagementTool", true);
    }
    }
    if (File.Exists("Setting.ini"))
    File.Delete("Setting.ini");
    }
    catch (Exception ex)
    {
    MessageBox.Show("Registry Keys exception " + ex.Message);
    }

    }


    I tried Directory.GetCurrentDirectory() to get file names and delte it, but it doesnt work. So I checked this line of code works file.Delete(filename). It delets the specified file. So it should delete the file during uninstall as its in the same folder.



    At the end I should say- I tried 2-3 different ways to access that file and delete it during uninstallation. but Its not delteting and throwing error some times and sometimes no exception at all.




    The exception was related to Access to SysWOW64AdvanceInstaller is
    denied




    FYI - MY App has <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> already.



    I tried solutions available on StackOverflow but its not working So I needed to ask a new question. So please let me know where I am mistaking. I am sure it is something very minor that I might be missing here










    share|improve this question



























      0












      0








      0








      I have a settings file created when user run the wpf application.
      I have created a custom uninstaller to delete some registry keys related to my app and to delete this setting file.
      But my file is not getting deleted.
      Here is the code -



       public override void Uninstall(IDictionary savedState)
      {
      base.Uninstall(savedState);

      try
      {
      using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true))
      {

      if (registryKey.GetValue("TeachingManagementTool") != null)
      {
      registryKey.DeleteValue("TeachingManagementTool", true);
      }
      }
      if (File.Exists("Setting.ini"))
      File.Delete("Setting.ini");
      }
      catch (Exception ex)
      {
      MessageBox.Show("Registry Keys exception " + ex.Message);
      }

      }


      I tried Directory.GetCurrentDirectory() to get file names and delte it, but it doesnt work. So I checked this line of code works file.Delete(filename). It delets the specified file. So it should delete the file during uninstall as its in the same folder.



      At the end I should say- I tried 2-3 different ways to access that file and delete it during uninstallation. but Its not delteting and throwing error some times and sometimes no exception at all.




      The exception was related to Access to SysWOW64AdvanceInstaller is
      denied




      FYI - MY App has <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> already.



      I tried solutions available on StackOverflow but its not working So I needed to ask a new question. So please let me know where I am mistaking. I am sure it is something very minor that I might be missing here










      share|improve this question
















      I have a settings file created when user run the wpf application.
      I have created a custom uninstaller to delete some registry keys related to my app and to delete this setting file.
      But my file is not getting deleted.
      Here is the code -



       public override void Uninstall(IDictionary savedState)
      {
      base.Uninstall(savedState);

      try
      {
      using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true))
      {

      if (registryKey.GetValue("TeachingManagementTool") != null)
      {
      registryKey.DeleteValue("TeachingManagementTool", true);
      }
      }
      if (File.Exists("Setting.ini"))
      File.Delete("Setting.ini");
      }
      catch (Exception ex)
      {
      MessageBox.Show("Registry Keys exception " + ex.Message);
      }

      }


      I tried Directory.GetCurrentDirectory() to get file names and delte it, but it doesnt work. So I checked this line of code works file.Delete(filename). It delets the specified file. So it should delete the file during uninstall as its in the same folder.



      At the end I should say- I tried 2-3 different ways to access that file and delete it during uninstallation. but Its not delteting and throwing error some times and sometimes no exception at all.




      The exception was related to Access to SysWOW64AdvanceInstaller is
      denied




      FYI - MY App has <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> already.



      I tried solutions available on StackOverflow but its not working So I needed to ask a new question. So please let me know where I am mistaking. I am sure it is something very minor that I might be missing here







      c# visual-studio windows-installer uninstall uninstaller






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 8:32







      Usha phulwani

















      asked Nov 19 '18 at 8:27









      Usha phulwaniUsha phulwani

      7412




      7412
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Advanced Installer: So you are using Advanced Installer? In the Files and Folders view, select the destination folder in question. In the right pane, right click inside the folder where the file to remove resides. Do you see "New File Operation"? Select "File Removal" and configure options.



          Remember to set the options properly. In particular "Remove On". Select on "Component Uninstall".



          File Removal






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370821%2fcustom-uninstall-not-deleting-file-in-net-application%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Advanced Installer: So you are using Advanced Installer? In the Files and Folders view, select the destination folder in question. In the right pane, right click inside the folder where the file to remove resides. Do you see "New File Operation"? Select "File Removal" and configure options.



            Remember to set the options properly. In particular "Remove On". Select on "Component Uninstall".



            File Removal






            share|improve this answer




























              0














              Advanced Installer: So you are using Advanced Installer? In the Files and Folders view, select the destination folder in question. In the right pane, right click inside the folder where the file to remove resides. Do you see "New File Operation"? Select "File Removal" and configure options.



              Remember to set the options properly. In particular "Remove On". Select on "Component Uninstall".



              File Removal






              share|improve this answer


























                0












                0








                0







                Advanced Installer: So you are using Advanced Installer? In the Files and Folders view, select the destination folder in question. In the right pane, right click inside the folder where the file to remove resides. Do you see "New File Operation"? Select "File Removal" and configure options.



                Remember to set the options properly. In particular "Remove On". Select on "Component Uninstall".



                File Removal






                share|improve this answer













                Advanced Installer: So you are using Advanced Installer? In the Files and Folders view, select the destination folder in question. In the right pane, right click inside the folder where the file to remove resides. Do you see "New File Operation"? Select "File Removal" and configure options.



                Remember to set the options properly. In particular "Remove On". Select on "Component Uninstall".



                File Removal







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 '18 at 22:40









                Stein ÅsmulStein Åsmul

                21.6k1357117




                21.6k1357117
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370821%2fcustom-uninstall-not-deleting-file-in-net-application%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Xamarin.form Move up view when keyboard appear

                    Post-Redirect-Get with Spring WebFlux and Thymeleaf

                    Anylogic : not able to use stopDelay()