Reputation: 1215
Here's my problem: I have files that are being generated in pairs by third party software. The files have the exact same name and both have a file extension of .ACS - the only difference I can find is that one file type is recognized as an ACS file and the other is recognized as a CSV file. I need to get all of the ACS type files. Normally I would just use something like this:
string[] files = Directory.GetFiles("\\somedrive\location", "*.ACS");
My issue is that this picks up both files and I need to ignore the file that has a type of csv. So, how can this be done? Is there a way to expose the file type property?
(The ACS files can be opened in notepad if it helps...I'm just doing some basic data manipulation with them).
Upvotes: 2
Views: 142
Reputation: 17166
You could look at the file itself, using urlmon.dll for example.
Check this out: http://www.pinvoke.net/default.aspx/urlmon.findmimefromdata
I'm doing this using code found here: Using .NET, how can you find the mime type of a file based on the file signature not the extension
Upvotes: 2