【问题标题】:Finding whether file is being copied or not in C++(in Windows)?查找文件是否在 C++(在 Windows 中)中被复制?
【发布时间】:2013-07-10 10:52:56
【问题描述】:

我想知道给定的文件是否被复制。最初我想做 fopen(_file) 因为 fopen 在文件被复制时返回 false 。但是这个想法在某些应用程序中打开文件时会失败(例如:在MS powerpoint中打开ppt时,fopen返回false)。我正在寻找一个文件的属性,它唯一地标识该文件是否被复制。即使在 boost::filesystem 中我也找不到这样的属性。使用Boost lib可以解决这个问题吗?有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: windows file-copying boost-filesystem file-attributes


    【解决方案1】:

    boost filesystem fstream 实用程序解决了这个问题

                boost::filesystem::fstream fileStream(filePath, std::ios_base::in | std::ios_base::binary);
    
    
                if(fileStream.is_open())
                {
                    //not getting copied
    
                }
                else
                {
                    //getting copied
                }
    

    【讨论】:

      猜你喜欢
      • 2018-05-09
      • 2014-06-15
      • 2012-05-30
      • 2020-03-20
      • 1970-01-01
      • 1970-01-01
      • 2012-09-27
      • 2012-11-24
      • 2015-07-19
      相关资源
      最近更新 更多