停止引发 Filewatcher 控件的创建事件以自动生成原始内容的临时文件
我在我的 winform 应用程序中使用 filewatcher 控件。我正在通过处理其事件来执行上传任务。
现在的问题是,当我在目录中创建任何新文档(在 FileWatcher 控制下监视)时,上传功能将启动并上传文档。(我想要的< /strong>),但在该目录中创建新文档时,系统会生成临时文件,并将其上传到服务器(我不想要)。
例如,如果我在 xyz 目录中创建一个名为 Microsoft Word Document.docx 的新 Word 文档(此目录在FileWatcher 控件),然后系统为该文档创建另一个文件,例如 ~$w Microsoft Word Document.docx。这两个文件都正在上传到服务器。
这里我以word文件为例。上传内容可以是任意的(不固定)。
I am using filewatcher control in my winform app. I am performing uploading task by handling its events.
Now problem is that when I create any new document in directory(which is watched under FileWatcher control) uploading function starts and it uploads the document.(Which I want) but with creating new document in this directory system generates temporary file and it also uploaded to the server(Which I don't want).
As for example if I am creating a new word document named Microsoft Word Document.docx in xyz directory(This directory is watched under FileWatcher control) then system create another file like ~$w Microsoft Word Document.docx for that doc. and this both files are uploading to server.
Here I have take an example for a word file. Uploading content may be any(not fix).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你能不能只检测临时文件名并忽略它?您可能会发现它有一些属性,这使得它显然不是一个普通文件,或者您可能只是发现了 Word 使用的命名约定。 (您真正想要一个以“$”开头的文件的可能性有多大?)
Can you not just detect the temporary filename and ignore it? You may well find it has some attributes which make it obviously not-a-normal-file, or you could just spot the naming convention which Word uses. (How likely is it that you'll really want a file beginning with "$"?)
所以我得到了一个解决方案。在将文件添加到上传队列中之前,我使用了一些验证。
如果我隐藏文件属性或其扩展名,那么我从那里返回。
就这样 :)
So I got a solution. I use a little validation before adding file in Queue for upload.
If I am getting file attribute hidden or its extension then I return from there.
Thats all :)