Here is the scenario:
这是场景:
I'm writing an app that will watch for any changes in a specific directory. This directory will be flooded with thousands of files a minute each with an "almost" unique GUID. The file format is this:
我正在编写一个应用程序来监视特定目录中的任何更改。这个目录将充斥着每分钟数千个文件,每个文件具有“几乎”唯一的GUID。文件格式是这样的:
GUID.dat where GUID == xxxxxxxxxxxxxxxxxxxxxxxxxxxxx (the internal contents aren't relevant, but it's just text data)
GUID.dat GUID == xxxxxxxxxxxxxxxxxxxxxxxxxxxxx(内部内容不相关,但只是文本数据)
My app will be a form that has one single text box that shows all the files that are being added and deleted in real time. Every time a new file comes in I have to update the textbox with this file, BUT I must first make sure that this semi-unique GUID is really unique, if it is, update the textbox with this new file.
我的应用程序将是一个包含一个文本框的表单,该文本框显示实时添加和删除的所有文件。每次有新文件进来时我都要用这个文件更新文本框,但是我必须首先确保这个半唯一的GUID真的是唯一的,如果是,用这个新文件更新文本框。
When a file is removed from that directory, make sure it exists, then delete it, update textbox accordingly.
从该目录中删除文件时,请确保该文件存在,然后将其删除,相应地更新文本框。
The problem is that I've been using the .NET filewatcher and it seems that there is an internal buffer that gets blown up every time the (buffersize + 1)-th file comes in. I also tried to keep an internal List in my app, and just add every single file that comes in, but do the unique-GUID check later, but no dice.
问题是我一直在使用.NET filewatcher,似乎有一个内部缓冲区在每次(buffersize + 1)-th文件进入时都会被炸毁。我还试图在我的内部保留一个内部列表应用程序,只需添加进来的每个文件,但稍后执行unique-GUID检查,但没有骰子。
2 个解决方案
#1
3
A couple of things that I have in my head:
我脑子里有几件事:
- If the guid is not unique, would it not overwrite the file with the same name, or is the check based on a lookup which does some external action (e.g. check the archive)? (i.e. is this a YAGNI moment?)
- I've used FileSystemWatcher before with pretty good success, can you give us some ideas as to how your actually doing things?
- When you say "no dice" when working with your custom list, what was the problem? And how were you checking for file system changes without FileSystemWatcher?!
如果guid不是唯一的,它是否会覆盖具有相同名称的文件,或者是基于查找执行某些外部操作(例如检查存档)的检查? (这是一个YAGNI时刻吗?)
我之前使用过FileSystemWatcher取得了相当不错的成功,你能否就我们实际做事情如何提出一些想法?
当您使用自定义列表时说“没有骰子”时,问题是什么?你是如何在没有FileSystemWatcher的情况下检查文件系统更改的?
Sorry no answer as yet, just would like to know more about the problem :)
对不起,还没有回答,只是想了解更多关于这个问题:)
#2
2
I suggest you take a look at the SHChangeNotify API call, which can notify you of all kinds of shell events. To monitor file creation and deletion activity, you may want to pay special attention to the SHCNE_CREATE and SHCNE_DELETE arguments.
我建议你看看SHChangeNotify API调用,它可以通知你所有类型的shell事件。要监视文件创建和删除活动,您可能需要特别注意SHCNE_CREATE和SHCNE_DELETE参数。
#1
3
A couple of things that I have in my head:
我脑子里有几件事:
- If the guid is not unique, would it not overwrite the file with the same name, or is the check based on a lookup which does some external action (e.g. check the archive)? (i.e. is this a YAGNI moment?)
- I've used FileSystemWatcher before with pretty good success, can you give us some ideas as to how your actually doing things?
- When you say "no dice" when working with your custom list, what was the problem? And how were you checking for file system changes without FileSystemWatcher?!
如果guid不是唯一的,它是否会覆盖具有相同名称的文件,或者是基于查找执行某些外部操作(例如检查存档)的检查? (这是一个YAGNI时刻吗?)
我之前使用过FileSystemWatcher取得了相当不错的成功,你能否就我们实际做事情如何提出一些想法?
当您使用自定义列表时说“没有骰子”时,问题是什么?你是如何在没有FileSystemWatcher的情况下检查文件系统更改的?
Sorry no answer as yet, just would like to know more about the problem :)
对不起,还没有回答,只是想了解更多关于这个问题:)
#2
2
I suggest you take a look at the SHChangeNotify API call, which can notify you of all kinds of shell events. To monitor file creation and deletion activity, you may want to pay special attention to the SHCNE_CREATE and SHCNE_DELETE arguments.
我建议你看看SHChangeNotify API调用,它可以通知你所有类型的shell事件。要监视文件创建和删除活动,您可能需要特别注意SHCNE_CREATE和SHCNE_DELETE参数。