Say there are three types of file I want to distinguish, pure text file, JavaScript file, and VB script file. Given file has no extension, how do I tell the file type programmatically?
If the file types are text, as in the examples given, you would need to parse the file content to determine the file type, other file types have a predefined structure which includes headers, such as .dll and .exe files, which follow the PE format (COFF on nix systems).