I'd like to be able to use an alternate data stream to store some synchronization information for files that are referenced in a database application I'm building.
However, every approach I've found on the web has failed in one way or another. Not being experienced at Win32 API programming I'm not sure why the failures are occurring. In some cases the method calls appear to succeed, only no alternate stream is created (i.e., I can't later read from the alternate file, nor can AlternateStreamViewer see it). In other cases the write succeeds, but the read fails because calling CreateFile() results in an invalid SafeFileHandle.
At this point I'd just like to find some working code. Or be advised that "ya can't get there from here". In which case I'll use another, less attractive option (e.g., encode the sync/reference information in the filename itself, and hope no one ever changes a file name).
I understand the request for what approaches I tried. But there were quite a few (I spent hours on this), and I was really interested in learning about offerings I hadn't tried.
However, you're right that it would've helped, as it turns out I was using one of the approaches -- the Trinet one referred to below -- incorrectly. I think the problem was that I hadn't yet created the "base" file for which I was trying to save an alternate stream.
Here are links to the code bases I tried: