如何知道在 Windows 中复制是否完成? [英] How to know if copying is finished in Windows?

查看:51
本文介绍了如何知道在 Windows 中复制是否完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个侦听位置的工具,最好是远程位置,如果创建了新文件夹或文件,它会将其下载到本地位置.

I am writing a tool that listens a location, preferably remote location, and if a new folder or file created, it will download it to a local location.

目前我正在使用 FileSystemWatcher 监听远程文件夹,当创建新文件夹/文件时,我启动一个计时器,如果计时器达到 X 分钟,它开始将其复制到本地.在监视"文件夹中创建新文件夹或文件会触发 FileSystemWatcher.Changed 但如果有很多子目录并且如果有大文件复制到监视文件夹,它有时会失败,它只会检测复制开始时它,我的计时器可以完成直到完成.

Currently I am listening the remote folder with FileSystemWatcher, when a new folder/file created, I start a timer and if timer reaches X minutes it starts to copy it to local. Creating a new folder or file in "watched " folder triggers FileSystemWatcher.Changed but it sometimes fail if there are a lot of sub-directories and if there is a large file copying to watched folder, it only detects it when copying started and my timer can finish until it is finished.

所以:我有 3 台远程计算机/位置,ABC

So: I have 3 remote computers/locations, A,B,C

A 开始将一些文件夹/文件复制到 BCB .

A starts to copy some folders/files to B and C listens to B .

C 如何检查 A 是否在使用或不使用 FileSystemWatcher 的情况下完成复制?我不想经常比较 BC 并复制其余文件.

How can C check if A is finished copying with or without FileSystemWatcher? I don't want to constantly compare B and C and copy rest of the files.

我检查了其他问题,但他们没有回答,或者我已经实施了这些解决方案.12,3

I checked other questions but they don't answer or I already did implement those solutions. 1, 2,3

推荐答案

我想你在问系统变更日志.也就是说,在您检测到需要复制文件和真正开始复制之间,总会有文件正在使用、已被删除、更新等情况.这是一篇古老但准确的文章,可为您提供更多详细信息.

I think you are asking about the system change journal. That said, there will always be cases where the file is in use, has been deleted, updated, etc. between the time you detect you need to copy it and when you really start copying. Here's an old but accurate article that can give you more details.

http://www.microsoft.com/msj/0999/journal/journal.aspx

来自文章摘要:

Windows 2000 更改日志是一个数据库,其中包含对 NTFS 5.0 卷上的文件或目录所做的每个更改的列表.每个卷都有自己的更改日志数据库,其中包含反映该卷文件发生的更改的记录和目录."

"The Windows 2000 Change Journal is a database that contains a list of every change made to the files or directories on an NTFS 5.0 volume. Each volume has its own Change Journal database that contains records reflecting the changes occurring to that volume's files and directories."

向下滚动到标题ReasonMask and ReturnOnlyOnClose

这篇关于如何知道在 Windows 中复制是否完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆