问题描述
我用 File.Move
从目录到另一个directory.The desitnation文件夹监控2GB左右移动大文件,如果有任何新的文件,这将是上传到CDN。但是,我们经历了一些局部的文件上传到CDN,这意味着,相应的文件上传到CDN而同样的文件是从源移动到目标目录。所以,我需要知道是否File.Move锁定该文件的目标文件夹,直到文件完成感动?
I use File.Move
to move large files around 2GB from a directory to another directory.The desitnation folder is monitored and if there is any new file, it will be uploaded to CDN. But we experienced some partial file upload to CDN which means, the respective file was uploaded to CDN while the same file was moving from source to destination directory. So, I need to know whether File.Move locks the file destination folder till the file is completed moved?
推荐答案
您的问题是在目标文件夹中的moonitoring。
Your problem is the moonitoring on the destination folder.
既然你有一个大的文件,它需要时间来复制它,发生了什么是:
Since you have a big file, it take time to copy it so what happend is :
- 您开始移动文件
- 监控系统踢并开始上传到CDN
- 文件被上传parialy
- 您完成移动文件。
这其中的一个缓解措施是,假设你的监控系统寻找一些extensation文件 - 移动 MyBigFile.ext
到 MyBigFile.ext.tmp
。完成后,其重命名为 MyBigFile.ext
,所以在监控踢时,将拥有完整的文件
One mitigation for this is , assuming your monitoring system searching for files with some extensation - moving MyBigFile.ext
to MyBigFile.ext.tmp
. after finish , rename it back to MyBigFile.ext
, so when monitoring kick in , it will have the complete file
这篇关于File.Move锁定在目标文件夹中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!