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…
You could try something like this:
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:
so you can change part of my answer to