View Full Version : identifying file types
BobLewiston
01-29-2009, 12:36 AM
Within a C# program, is there any way to tell if a file is a text file or not? I mean a real way, not just basing your conclusion on a file name extension.
oracleguy
01-29-2009, 03:13 AM
I suppose you could open it up and read the first few characters and if they fall within the valid character range, you'd know it is a text file.
DELOCH
02-07-2009, 02:43 AM
All files contain bytes, there is no way to understand file type without any definitions of the structure of the file.
For example .BMP file has a certain structure it must follow. Otherwise ms paint chokes on it and spits it out.
If you are trying to crack a resource file, your best way is to look up it's extension, reading first few lines of the file(sometimes has hints). Or loading it from different programs...
To answer your question, no way to identify a file without knowing how to parse it. Since text files have no structure... It would be very difficult without an extension...
Though you can always try
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.