I would like to be able to use an alternative data stream to store some synchronization information for the files referenced in the database application that I am creating.
However, every approach I found on the Internet has somehow failed. Having no programming experience with the Win32 API, I don't know why crashes occur. In some cases, method calls seem successful, only no alternative stream is created (i.e. I cannot read from the alternative file later, and also can not see AlternateStreamViewer). In other cases, writing succeeds, but reading fails because calling CreateFile () results in an invalid SafeFileHandle.
At this point, I just wanted to find some kind of working code. Or keep in mind that "I can't get from here." In this case, I will use another, less attractive option (for example, encode synchronization / link information in the file name itself and hope that no one ever changes the file name).
I understand the request for what approaches I tried. But there were many (I spent several hours on this), and it was very interesting for me to learn about the offers that I had not tried.
However, you are right that this would help, because, as it turned out, I used one of the approaches - Trinet, mentioned below - is wrong. I think the problem is that I have not yet created a “base” file for which I tried to save an alternate stream.
Here are the links to the codebases I tried:
user553671
source share