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 6801615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:07:18+00:00 2026-05-26T19:07:18+00:00

I have an application that should unzip and install some other application, i get

  • 0

I have an application that should unzip and install some other application, i get new Zip file with installation image via network and then should unzip it and install. All file except the part that Zip file comes with different name each time because of version change and all my C:\ has a lot of .zip files with different versions. Msi file is not overwritten by Zip i’m using but i’m more than fine with just deleting it prior to unzipping.

I want to delete all .msi and .zip files on C:.
How can i do that via C#?

thanks…

  • 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-26T19:07:19+00:00Added an answer on May 26, 2026 at 7:07 pm

    You could try something like this:

    DirectoryInfo di = new DirectoryInfo(@"C:\");
    FileInfo[] files = di.GetFiles("*.msi")
                         .Where(p => p.Extension == ".msi").ToArray();
    foreach (FileInfo file in files)
        try
        {
            file.Attributes = FileAttributes.Normal;
            File.Delete(file.FullName);
        }
        catch { }
    

    Note that I first try to set attributes to “normal”, because File.Delete() fails if file is read-only…
    Note the use of GetFiles(): see this link for details.

    EDITED:
    If you need to get more than one extension you could use this:

    public List<FileInfo> GetFiles(string path, params string[] extensions)
    {
        List<FileInfo> list = new List<FileInfo>();
        foreach (string ext in extensions)
            list.AddRange(new DirectoryInfo(path).GetFiles("*" + ext).Where(p =>
                  p.Extension.Equals(ext,StringComparison.CurrentCultureIgnoreCase))
                  .ToArray());
        return list;
    }
    

    so you can change part of my answer to

    List<FileInfo> files = GetFiles(@"C:\", ".msi", ".zip");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have application that brings response via Ajax and creates 5-20 new jQuery click
I have a web application that should behave differently for internal users than external
I have a console application that should do best effort logging to a database
I have a LAMP (Linux/Apache/MySQL/Php) application that I should release soon. Even if I've
I have a Flex application that seems larger than it should be. There is
I'm creating an intranet asp.net mvc application that everyone in the company should have
I have created an SMS application in .NET. I wanted that the application should
i have a alarm application that should print a toast message every 1 minute.But
I have an application that originally needed to connect to Sybase (via ODBC), but
I have a file upload function in my asp.net mvc application that allows users

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.