|
-
Aug 13th, 2003, 09:25 AM
#1
Thread Starter
Addicted Member
File System / Directory Events
Hi,
I received some sample source code in an e-mail that showed how you can create an instance of a filesystemobject (or something like that), link it to a directory, and add an event to it that fires when a new file is written to that directory. Does anybody have an example of this? The sample that I saw was in VB.
Thanks in advance,
DJ
-
Aug 14th, 2003, 03:25 AM
#2
Hyperactive Member
I dont have ready example but here some code to get you started:
Code:
using System;
using.System.IO;
using System.Threading;
class watchFS
{
static void FSErrorCallback(object o, ErrorEventArgs eea)
{
Console.WriteLine("Error");
}
static void FSRenamedCallback(object o, RenamedEventArgs rea)
{
Console.WriteLine("Renamed");
}
static void FSEventCallback(object o, FileSystemEventArgs fsea)
{
Console.WriteLine("Event", fsea.ChangeType, fsea.FullPath)
}
static void main(string[] args)
{
FileSystemWatcher fsw = new FileSystemWatcher("Path goes here");
fsw.Created += new FileSystemEventHandler(FSEventCallback);
//subscribe to all other events here
fsw.EnableRaisingEvents = true;
Console.ReadLine(); //Now wait for events
}
Hope that gets you going
Stephan
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
-
Aug 14th, 2003, 07:52 AM
#3
Thread Starter
Addicted Member
Hi,
Many thanks for that - got it all working. However, I have completed my project, and found that my compiled program takes 8.5Mb of memory! And there are only about 10 lines of code!
Hopefully somebody can help me with an equivalent in C++? Can anybody help me?
Thanks,
DJ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|