Reputation: 4264
Is there a way to determine if a file is a binary or text file using the the File Management functions or MFC?
In the File Management functions, GetFileType doesn't seem to distinguish between binary and text files. Same with the dwFileAttributes attribute here.
In MFC, I tried looking at CFile::GetStatus(), but the m_attribute doesn't say anything about whether files are binary or text.
Does anyone know a way to do this using one of these two libraries? Thank you.
(I'd like to know because I am trying to make a function that recursively goes through a directory. I rewrite the text files (using CStdioFile) and replace some words here and there... but it seems to screw up any images I have in the directory. I'd like to be able to copy the images too... but i need a way to distinguish between binary and text files so I can treat them differently.)
Upvotes: 1
Views: 682
Reputation: 394
As far as I know, there's no simple API to do this, MFC or otherwise. However, there's a bunch of useful ideas in these similar questions:
How do I distinguish between 'binary' and 'text' files?
How to identify the file content as ASCII or binary
Upvotes: 1