Microsoft がTransactional NTFS (TxF) を廃止した場合:
Microsoft は、開発者がアプリケーションのニーズを満たすために別の手段を利用することを強くお勧めします。TxF が開発された多くのシナリオは、より単純ですぐに利用できる手法を使用して実現できます。さらに、TxF は、Microsoft Windows の将来のバージョンでは利用できなくなる可能性があります。
TxF は強力な API セットですが、Windows Vista 以降、この API プラットフォームに対する開発者の関心は非常に限られていました。その主な理由は、開発者がアプリケーション開発の一環として考慮しなければならない複雑さとさまざまなニュアンスです。その結果、Microsoft は、Windows の将来のバージョンで TxF API を非推奨にすることを検討しており、より多くの顧客にとってより価値のある他の機能や API に開発と保守の取り組みを集中させることができます。
これは、次の代替手段が必要であることを意味します。
私の取引要件はかなり単純です - 2 つのファイルを移動します。
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);
}
私は+に変わることMoveFile
を考えました:CopyFile
DeleteFile
CopyFile(testResults, testResultsArchive); //throws if there's a problem
CopyFile(cdcResponse, cdcResponseArchive); //throws if there's a problem
DeleteFile(testResults);
DeleteFile(cdcResponse);
しかし、バグのある解決策ではなく、良い解決策を望んでいました。だから私は再試行します:
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);
}
バグのある解決策ではなく、良い解決策を望んでいたことを除いて。