Given that Microsoft has deprecated Transactional NTFS (TxF):
Microsoft strongly recommends developers utilize alternative means to achieve your application’s needs. Many scenarios that TxF was developed for can be achieved through simpler and more readily available techniques. Furthermore, TxF may not be available in future versions of Microsoft Windows.
While TxF is a powerful set of APIs, there has been extremely limited developer interest in this API platform since Windows Vista primarily due to its complexity and various nuances which developers need to consider as part of application development. As a result, Microsoft is considering deprecating TxF APIs in a future version of Windows to focus development and maintenance efforts on other features and APIs which have more value to a larger majority of customers.
This means that i need an alternative to:
My transacted requirements are fairly simple - move two files:
tx = BeginTransaction();
{
MoveFile(testResults, testResultsArchive); //throws if there's a problem
MoveFile(cdcResponse, cdcResponseArchive); //throws if there's a problem
CommitTransaction(tx);
}
finally
{
CloseHandle(tx);
}
i've thought about turning MoveFile
in to CopyFile
+ DeleteFile
:
CopyFile(testResults, testResultsArchive); //throws if there's a problem
CopyFile(cdcResponse, cdcResponseArchive); //throws if there's a problem
DeleteFile(testResults);
DeleteFile(cdcResponse);
But i was hoping for a good solution, not a buggy solution. So i try again:
CopyFile(testResults, testResultsArchive); //throws if there's a problem
CopyFile(cdcResponse, cdcResponseArchive); //throws if there's a problem
try
{
DeleteFile(testResults);
}
catch (Exception e)
{
DeleteFile(testResultsArchive);
throw e;
}
try
{
DeleteFile(cdcResponse);
}
catch (Exception e)
{
DeleteFile(cdcResponseArchive);
}
Except i was hoping for a good solution, not a buggy one.
File.Delete(path);
; which suffers the problem perhaps not being able to delete the file. The "real" solution involves usingCreateFile
, and re-implementingCopyFile
, so that you can retroactively signal the handle to "delete file when the handle is closed". But if the issues associated with transactional integrity were not an overriding concern (and i were using .NET), i'd use something like this. Accepted. – Surbeck