Tell me how to check the type or file extension? I check the file for an extension at the end of the name. But I know that you can change it and, let's say, the file is a picture and we changed the extension to txt .

Thank.

  • one
    That is, the program should understand what kind of file, even if we changed the extension? that is, they took png and changed to txt. and the program tells you that it reads txt, but is it really a png? - Senior Pomidor
  • @SeniorPomidor not. the program will say something png . Once heard this. For example, if you open a picture with Notepad++ then at the beginning there will be a format or extension, and even if you change the extension, the file will still have that. - Tsyklop
  • 2
  • 2
    File content is a set of bytes. How to interpret them is up to you. The extension is part of the file name. It is possible to determine the format of a file by its contents, if it conforms to the format specification, i.e. written according to the rules by which you can determine the format. In general, this is not solved. - ilsu87

0