Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6179911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:45:09+00:00 2026-05-24T00:45:09+00:00

I have created installer which needs to delete some files and folder if they

  • 0

I have created installer which needs to delete some files and folder if they already exists and replace with new one.

When the user clicks on install, the installer prompts for UAC. On selecting Yes, the installer will call the method to delete existing files and folder. But it is unable to delete the files and folder. Code I am using is DI.Delete(path). It gives this error

Access to the path 'CodeCreate.aspx' is denied.
   at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive)
   at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive)
   at System.IO.DirectoryInfo.Delete(Boolean recursive)
   at CustomizationCA.CustomActions.DeleteExistingFilesAndFolder(Session session)

While if I run command prompt as administrator and then using “msiexec /i Setup.msi” command, it deletes those files and folder.

And when using Directory.Delete(path,true); I am getting this as exception

Exception thrown by custom action:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.
   at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly)
   at System.Diagnostics.EventLog.SourceExists(String source, String machineName)
   at System.Diagnostics.EventLog.VerifyAndCreateSource(String sourceName, String currentMachineName)
   at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte rawData)
   at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte rawData)
   at System.Diagnostics.EventLog.WriteEntry(String source, String message)
   at CustomizationCA.CustomActions.DeleteExistingFilesAndFolder(Session session)

I am using WIX tool to create installer.

If I go to properties of particular file and then give full permission to all users and then try to delete the file, the file is getting deleted.
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:45:11+00:00Added an answer on May 24, 2026 at 12:45 am

    Check to see if the folder or file is read-only or not. Bring files to normal state first.

    Use this code before deleting any and every file in your directory

    File.SetAttribute(path, FileAttributes.Normal);
    File.Delete(path);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using WiX (Windows Installer XML) I have created an MSI installer which installs Word
I have created a dynamic(.so) library which bundles some functionality for a storage backend
I have created an installation package using Wix which installs a Windows service on
I have created a windows installer for a windows forms app as an MSI.
In VS2008 I have written a C# service, an installer, and have created a
I want to create a installer which would just dump few files and folders
I have a project which I created a few days ago as a test
I have a script that appends some rows to a table. One of the
So I have created a piece of software which I wanna package and post
I developing window application in C#. I created one installer with this windows application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.