gpt4 book ai didi

transactional - 使用事务性 NTFS 的替代方案

转载 作者:行者123 更新时间:2023-12-04 05:56:25 25 4
gpt4 key购买 nike

鉴于微软有 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.



这意味着我需要一个替代方案:
  • CreateTransaction
  • MoveFileTransacted
  • CommitTransaction

  • 我的交易要求相当简单 - 移动两个文件:
    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);
    }

    我想过转 MoveFileCopyFile + 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);
    }

    除了我希望有一个好的解决方案,而不是一个有问题的解决方案。

    最佳答案

    从链接:

    As a result, Microsoft is considering deprecating TxF APIs



    还没死呢!我不知道为什么他们会删除 Windows 的原子文件系统 API,即使它还没有得到广泛支持。应该有一个 .NET BCL 以便于使用 TxF 作为初学者。对网络副本的 TxF 样式支持也很棒。

    如果有的话,微软应该改进 API!

    关于transactional - 使用事务性 NTFS 的替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13420643/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com