The problem: there is a log file in which several streams are written all the time. The problem is that on Windows 10 and Windows 8.1 this log on disk takes 4GB. That is, if you look at the file properties, it says: Size: 8.25MB (8,661,191 bytes); Size on disk: 4.04GB (4,345,872,384 bytes). In fact, there is not much information in the file. On Windows 7, everything is displayed normally. The file system in both cases is NTFS. I understand that without the code of the logger class itself and without the code that writes these logs, it is possible to assess the situation, but unfortunately, there is no possibility to drop the code. Who has any thoughts why this may be and in what direction to dig the solution to the problem?

  • Is compression used on this disc? - Daniel Protopopov
  • I can not exactly answer your question, because I do not understand what I mean. But nothing was configured manually. Net Windows - rudolfninja
  • Probably, when creating the file, its length was specified in the same way as the SetFilePointer functionality in C ++ or FileStream. SetLength - this is usually used for pre-allocating the buffer for subsequent recordings. The size of the current information is correct, and the total size of the dedicated disk for it is 4 GB - Daniel Protopopov
  • The file is created using the CreateFile function. As far as I know, there is no way to specify the length of the file. SetFilePointer is used only in the following variation: SetFilePointer(m_hFile,0,0,FILE_END); And why, then, on Windows7 everything is OK, but not on Windows10? - rudolfninja
  • And you do not copy the file yourself on windows 7? Indeed, in this case, the information in the file will be copied directly, and not the set size. - Daniel Protopopov

1 answer 1

Guys, thank you all. The problem was in the code. The DWORD (-1) value was passed to the WriteFile function as a parameter responsible for the number of bytes to be written to the file.