1

I am writing files from my Assets folder to the device's internal memory using Assets.Open().

However, I do not want to write the file every time the application is run.

Only when the file has chanced since I last written it.

How can I view the asset's last modified date or some kind of hash so that I can rewrite the asset to file only when it has changed since the last build?

John
  • 5,942
  • 3
  • 42
  • 79
  • https://stackoverflow.com/questions/16340/how-do-i-generate-a-hashcode-from-a-byte-array-in-c – Jason Aug 03 '20 at 22:09
  • @Kasalwe the asset folder in visual studio refers to a real local directory and editing the files in that folder updates in the assets built into the application. – John Aug 03 '20 at 22:47
  • @Jason I don't want to read all the bytes of all the files since that would be extremely slow. – John Aug 03 '20 at 22:48
  • Then you probably need to store some metadata about when the file was last updated and/or which version, and update appropriately. Or even store a version # as part of the file name. There are a lot of ways to approach it but all will require some work – Jason Aug 03 '20 at 22:52
  • @Jason I'm looking to automate it. Not manually track all the files. Otherwise I can just rewrite them. – John Aug 03 '20 at 23:14
  • you really didn't give a lot of context about what you're doing, so it's hard to provide alternate suggestions – Jason Aug 04 '20 at 00:26
  • @Jason I was quite clear of what I'm doing and what I would like to achieve. I'm writing assets to file and would like to have some kind of timestamp of when the asset was last changed to know when to rewrite the changed asset to file on the next run. – John Aug 04 '20 at 03:08
  • You asked for a hash, I gave you a link to do that, then you said that wasn’t acceptable. Knowing roughly how many files, how large they are, what kind of data they contain, how often they change, etc are all relevant info that might drive different kinds of suggestions. – Jason Aug 04 '20 at 03:14
  • I was referring to an existing hash or checksum that was part of the file attribute. Not generating them myself. – John Aug 04 '20 at 03:50
  • Have you tried this? https://stackoverflow.com/a/10824137/11104068 – Saamer Aug 12 '20 at 13:15

0 Answers0