FileSystemObject 是否知道文件不完整?

发布于 2024-12-10 05:35:36 字数 335 浏览 0 评论 0原文

是的,我仍在使用经典 ASP。

我即将编写一个脚本,每 5 分钟检查一次服务器上的目录,以查找我办公室新上传的照片,并将照片传输到另一个位置。我使用 ASP 和 FileSystemObject 作为应用程序,Windows Schedule 调用它。

我想知道的是:如果用户通过 FTP 发送 150 张照片,我的应用程序将不会知道用户是否已完成上传。然后应用程序将逐一检查文件并传输它们。如果我的用户的连接速度比我的应用程序的速度慢,则脚本最终可能会遇到当前正在上传的文件...

我的应用程序会认为该文件已完成还是会知道它正在上传中并不管它吗?如果它确实抓住它并传输半张照片,我怎样才能阻止这种情况发生?

Yes, I'm still using Classic ASP.

I'm about to write a script that checks a directory on the server, every 5 minutes, for newly uploaded photos, by my office, and to transfer the photos to another location. I'm using ASP and the FileSystemObject as the application and a Windows Schedule calls it.

What I would like to know is: If the user is sending 150 photos, by FTP, my application is not going to know if the user has finished uploading, or not. So then the application will go through the files one-by-one and transfer them. If my user has a slower connection than the speed of my application, the script may eventually come across the file that is currently being uploaded...

Will my application grab that file thinking it's complete or will it know that it's in the middle of upload and leave it alone? If it DOES grab it and transfers half a photo, how can I stop this from happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌化 2024-12-17 05:35:36

没有好的方法来测试这一点,很大程度上取决于上传器的工作方式。

当前打开用于写入访问的文件在上传者创建它时不太可能允许您的代码移动它。尝试移动它会导致共享冲突或类似错误。因此,使用 On Error Resume Next 来保护该代码部分就可以了。让您的代码跳过该文件,因为您知道下次轮询时会再次选择该文件。

There is no good way to test for that, much depends on how the uploader is working.

Its highly unlikely that a file currently open for write access while the uploader creates it is going to allow your code to move it. An attempt to move it will result in a sharing violation or similar error. So protecting that section of code with an On Error Resume Next would do it. Have your code skip that file in the knowledge that it will be picked up again when the next poll comes round.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文