文件上传的最佳实践 [英] Best Practice for File Upload

查看:98
本文介绍了文件上传的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI



我目前正在运行一个程序,我将文件导出到FTP服务器和另一个收集文件的进程。



由于进程每隔5分钟运行一次,我发现有时上传到FTP服务器的文件有时在其他进程开始运行之前尚未完成,因此只有一半的文件从FTP中收集。



我最好的方法是确保完整的文件被拾取?

HI

I currently run a process where i export a file to an FTP server and another process that collects the file.

As the process runs every 5mins i found sometimes that the file being uploaded to the FTP server is sometimes not yet completed before the other process starts running so only half the file gets collected from the FTP.

What would be the best way for me to ensure that the complete file gets picked up?

推荐答案

奇怪的是你没有得到ACCESS DENIED错误。我建议首先通过使用 FileShare.None FileStream 来检查对文件的完全访问权限的第二个进程 >。如果失败,请等待几秒钟,然后再次尝试,直到超时或完全访问。然后才开始实际处理。
Strange that you do not get an ACCESS DENIED error. I suggest the "second process" to check for full access to the file first, by creating a FileStream with FileShare.None. If that fails, wait a few seconds, then try again till a timeout or full access. Only then start the actual processing.


这篇关于文件上传的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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