Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File/Folder Sniffers
Message
From
21/12/2000 02:03:00
 
 
To
20/12/2000 23:43:04
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00455763
Message ID:
00455772
Views:
43
>I'd like to write a file/folder sniffer in VFP and was wondering if there might be a class out in public domain that already does this.
>
>I'd like this sniffer to be able to poll folders on a server and when certain files are found, it should be able to move them to; say, backup folders and insert the file contents into SQL tables.
>
>How would I prevent this sniffer program from using 100% of the CPU on the server. And would it be better to create it as an executable or DLL?
>

You could use a recursive ADIR() or FSO object to spin through the directory on a timer basis, and if new files are found, process them and post them into your backup directory. You could use the API call FindFirstChangeNotification() - Houston Brennan posted a File #001318 which implements that on a timer an can return a list of files in a subfolder tree with changes based on a timer, when you find a new file, you would then process and copy it. If you were concerned about monopolizing the processor, you could launch a second process to copy and process the file; CreateProcess() can start an application running at a lower than normal priority; you could modify the STARTUPINFO structure created in my API_APPRUN class in the Files section to start a process running at below normal priority when a new file was found to process it.

I'd think that you'd want to create at least part of this as a .EXE so it could be launched on demand and run at low priority; YMMV. I probably would not use VFP for this unless someone held a gun to my head - writing it in C++ using ATL would allow you to write this to eat no processor time polling, write it multithreaded and respond to the event notification instead of polling the status, and to vary its priority, and perhaps run free-threaded, with overlapped I/O, and it would have a far smaller footprint. You can perform the database I/O using ADO. C++ offers other advantages, inclusing the ability to run it as a service easily. It also eventually will offer an easy port to C#, making it managed code under .NET

>Thanks for the help.
>
>Dan
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform