When you create a file, create it with exclusive rights, or at least with write access sharing disabled, then write to it as needed. Nobody else will be able to open the file for writing until you close it first.
In fact, NativeXML already does exactly that when saving XML to a file via its SaveToFile() method. It uses a TFileStream, and that is the default behavior of TFileSteam when creating a new file.
But, if you need more control over the access rights, then you can create your own TFileStream object so you can fill in its constructor parameters as needed. Or create a THandleStream object that refers to a file handle that you create using Window's CreateFile() API directly. Then you can have NativeXml write to that stream via its SaveToStream() method.
When you create a file, create it with exclusive rights, or at least with write access sharing disabled, then write to it as needed. Nobody else will be able to open the file for writing until you close it first.
In fact, NativeXML already does exactly that when saving XML to a file via its
SaveToFile()
method. It uses aTFileStream
, and that is the default behavior ofTFileSteam
when creating a new file.But, if you need more control over the access rights, then you can create your own
TFileStream
object so you can fill in its constructor parameters as needed. Or create aTHandleStream
object that refers to a file handle that you create using Window'sCreateFile()
API directly. Then you can have NativeXml write to that stream via itsSaveToStream()
method.