鉴于Microsoft已弃用Transactional NTFS(TxF):
Microsoft强烈建议开发人员使用其他方法来满足您的应用程序需求.可以通过更简单和更容易获得的技术来实现TxF开发的许多场景.此外,在未来的Microsoft Windows版本中可能无法使用TxF.
虽然TxF是一组功能强大的API,但自Windows Vista以来,开发人员对此API平台的兴趣非常有限,主要是由于其复杂性和开发人员在应用程序开发过程中需要考虑的各种细微差别.因此,Microsoft正在考虑在未来版本的Windows中弃用TxF API,以便将开发和维护工作集中在对大多数客户更有价值的其他功能和API上.
这意味着我需要一个替代方案:
我的交易要求相当简单 - 移动两个文件:
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);
}
Run Code Online (Sandbox Code Playgroud)
我已经考虑过转向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);
Run Code Online (Sandbox Code Playgroud)
但我希望有一个好的解决方案,而不是一个错误的解决方案.所以我再试一次:
CopyFile(testResults, testResultsArchive); //throws if there's a problem
CopyFile(cdcResponse, cdcResponseArchive); //throws if there's a problem …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我想用FILE_FLAG_DELETE_ON_CLOSE打开一个临时文件.但是在某些情况下,临时文件需要保留并且非常大
我想删除打开的句柄上的FILE_FLAG_DELETE_ON_CLOSE属性?这可能吗?复制文件的内容或重命名不是我想要的,我想删除该属性.这是由于如何我办理一些写在我的应用程序关闭句柄将打开我的比赛状态