文件夹事件中的新文件

编程入门 行业动态 更新时间:2024-10-23 02:06:59
本文介绍了文件夹事件中的新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人可以帮助我了解如何构建运行24/7的软件来侦听特定文件夹(例如C:\Actions),并且每次我在该文件夹中放置一个新文件时,该软件都需要来读取和处理它。

Can someone please help me to understand how to build a software that run 24/7 that listen to a specific folder (ex. C:\Actions) and each time I place a new file in that folder, the software needs to read and processing it.

如果文件夹中没有文件,则软件不应只等待下一个文件来做。

If there isn't files in the folder the software shouldn't do nothing only to wait to the next file to come.

文件(action1.txt)内容(1 + 1)的示例

Example of the file (action1.txt) content (1+1)

软件正在处理(1 + 1 ),将答案(2)保存到其他文件夹中,然后从 C:\Actions\文件夹中删除文件(action1.txt)。

The software is processing (1+1), saving the answer(2) to anther folder and delete the file(action1.txt) from the "C:\Actions\" folder.

我知道

我很难理解如何仅当文件夹中有新文件时如何触发软件以及如何运行24/7的软件,而不会使用太多的内存或导致内存泄漏……

I'm having difficulty to understand how to trigger the software only when there is new file in the folder and how to run the software for 24/7 without using so much memory or causing to memory leakage…

到目前为止,我已经以原始的循环方式使用它,每60秒循环一次(睡眠)我正在检查文件夹中的新文件s。

Till now I've used it in the primitive way of looping endless and each 60 sec (Sleep) I'm checking the folder for new files. That's so useless and not so effective.

如果有人可以帮助我了解如何使其更有效,我会很高兴。

I'll be happy if someone can help me to understand how to make it more effective..

非常感谢

推荐答案

了解此类 msdn.microsoft/en-us/library/system。 io.filesystemwatcher(v = vs.110).aspx ,您就可以开始了。它具有所需的事件。

Understand this class msdn.microsoft/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx and you are ready to go. It has the needed events.

更多推荐

文件夹事件中的新文件

本文发布于:2023-10-30 19:25:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1543775.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   新文件   事件中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!