0

I create Win32 app. Starting the program it will reload some data from specific folder. But I don't want to reload if the folder hasn't any change.

So I need to keep checksum of the folder for using compare between two folders (current and previous version).

How to get checksum value from a folder?

Fame th
  • 1,018
  • 3
  • 17
  • 37
  • 3
    In order to calculate folder checksum you will have to reread the whole folder which defeats the purpose of avoiding reloading data. – user7860670 May 07 '20 at 08:50
  • 1
    There is no such thing as a "checksum of a folder". What are you _actually_ trying to achieve? This sounds very much like an [XY Problem](http://xyproblem.info/) – Jabberwocky May 07 '20 at 08:50
  • 1
    If there's built-in functionality that supports this on Windows then that's news to me. Incidentally, having identical CRC32s does not guarantee that the two files are identical. – 500 - Internal Server Error May 07 '20 at 08:50
  • Out of curiosity... Assuming you store the CRC32 for a folder in a separate file with a "reserved" name. How will you recognize whether it's still valid or became dirty because files in that folder have been modified, removed, or added? – Scheff's Cat May 07 '20 at 08:51
  • It seems that Windows somehow caches thumbnails for folders. From my personal experience, it seems to have a "mechanism" to update the thumbnails if necessary. However, I often enough saw as well that this "mechanism" fails from time to time and I had to update manually (e.g. in Explorer by pressing [F5]). – Scheff's Cat May 07 '20 at 08:53
  • @Scheff I am forget to tell something. After I can get CRC32 result . I will keep it on server. So they will separated from interesting folder. – Fame th May 07 '20 at 08:55
  • @Fameth please [edit] your question and put all relevant information into the question. I'm also still waiting for an answer to my previous comment – Jabberwocky May 07 '20 at 08:57
  • 2
    However, that doesn't change my concerns. ;-) Remembering the time stamps of last modification for files of a folder (or use them for CRC32 checksum somehow) might be an alternative. So, at least, you don't need to re-read the whole folder contents byte for byte... – Scheff's Cat May 07 '20 at 08:58
  • I have two questions. 1. What data do you need from specific folder? 2. What are any changes to the folder? – Strive Sun May 08 '20 at 07:00
  • 2
    You could compare the two folders one time, then keep the time stamps of all the files. Then for later checks, you only need to check the time stamps to see if a file was changed. If the archive bit is not needed for other programs you could clear the archive bit for each file, and look for files with the archive bit set. If using Windows, this can be done using console command line dir /Aa /s. Programs like windiff will compare two directory trees and offer the option to copy newer files to replace older files. – rcgldr May 12 '20 at 04:11
  • 1
    Roundabout method to achieve what you're trying to do, but this answer could provide some useful items for detection depending on how much control you have over what is happening in the folders that are subject to change: [Rules for “Date Modified” of folders in Windows Explorer](https://stackoverflow.com/a/46428666/6610379) – Phil Brubaker May 12 '20 at 09:57

0 Answers0