[Qt-interest] The way to determine if a file is ascii file.

birman birman at mac.com
Wed Apr 21 15:03:48 CEST 2010


Dear All,

Could you tell me the way to determine if a file is ascii (text) file?

   QFile file(binaryFileName);
   if (!file.exists())
   {
      return false;
   }
   	
   if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
   {
      return false;
   }
   
   QTextStream stream(&file);
   QString data = stream.readAll();

I tried to write and execute the code as describe above.
But, I seem that the binary file was opened and read as text file.

Best regards,

birman



More information about the Qt-interest-old mailing list