0

有没有办法在不尝试打开文件的情况下知道文件是在 C# 中“正在写入”还是“完成复制”?

4

2 回答 2

0

It depends on the process which is working with file, example - if you have initiated the copying and trying to find out if the file is completed copying or not?

if the expectation is some other process is trying to write the file and you are expecting to capture the status of it? - In this case technically not possible as the file system will not give handle unless the file is completely written.

If the file already exists and another process is writing into file - it will be only dirty ready to get the contents. there is technically no LOCK on the file unless process actually tries to save / overrite.

Please be more specific on the question

于 2013-05-28T06:32:51.453 回答
0

FileInfo 类不支持这些回调。也许您可以编写自己的类来执行此操作。看看http://www.pinvoke.net/default.aspx/kernel32.CopyFileEx

于 2013-05-25T17:30:35.110 回答