 |
|
 |
I built a windows service using FileWatcher object, however, I am monitoring for creation files on a window server 2003, when the file is created in the folder, the services is not picking it up after some hours. I made sure that the user account is running has full rights on the network folde. I don't understand why this is happening, becuase when i restart the service it works again. Which means the service only works for limited time.
by
Mike zuluboy Maseko
"dont try to be someone because everyone is taken"
|
|
|
|
 |
|
|
 |
|
 |
Hi there,
I would like to append to a .csv file the details from the file system watcher. So when the folder I am watching gets updated I would like the file name, the event (created, deleted etc), date and time to be logged in a .csv file.
Can anyone help me with this? My file system watcher is running from a console app and is working I just don't know how to get the details in a .csv file.
Cheers
static void Main(string[] args)
{
FileSystemWatcher watcher = new FileSystemWatcher();
Console.WriteLine("FileSystemWatcher Started....");
watcher.Path = @"C:\Uploader\TransientStorage";
watcher.IncludeSubdirectories = false;
watcher.Filter = "*.jpg";
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);
watcher.EnableRaisingEvents = true;
Console.WriteLine(@"Press 'q' to quit app.");
while (Console.Read() != 'q') ;
}
private static void OnChanged(object source, FileSystemEventArgs e)
{
Console.WriteLine("File: {0} {1}!", e.Name, "has been " + e.ChangeType);
}
private static void OnRenamed(object source, RenamedEventArgs e)
{
Console.WriteLine("File: {0} renamed to\n{1}", e.Name, e.ChangeType);
}
|
|
|
|
 |
|
 |
Good Post, It realy helpful for basic window services as wel as FileWatcher use.
Thank You
|
|
|
|
 |
|
 |
I have also only see the User System. Can anybody help me to display the username how have delete or change any files.
And what must i do to dont display delete *.tmp or other temporär Files
Thanks Holger
|
|
|
|
 |
|
 |
Hi,
How do I create the report?
Thanks
|
|
|
|
 |
|
 |
I added a simple win form project with a button.
Added a reference to FileSysWatcher service.
In the button click event I have:
PrintReport.Print();
The problem:
I can not get past this line:
string logFilePath = Util.GetSetting("LOGFILENAME");
Any thoughts?
Thanks
|
|
|
|
 |
|
 |
Whenever I start the service it stops with an IO Exception. The Service's ErrorLogFile file cannot be accessed because the Service is using it?
Service cannot be started. System.IO.IOException: The process cannot access the file 'C:\FileSysWatcher\ErrorLogFile\Log.txt' because it is being used by another process.
at FileSysWatcher.Util.WriteToErrorLogFile(Exception sourceException)
at FileSysWatcher.FileSysWatcher.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
|
|
|
|
 |
|
 |
Please try this
fs = new FileStream("Log.txt", FileMode.OpenOrCreate | FileMode.Append, FileAccess.Write, FileShare.Write);
|
|
|
|
 |
|
 |
I think this will solve your problem http://bloggingabout.net/blogs/jschreuder/archive/2006/07/06/12886.aspx
|
|
|
|
 |
|
 |
Hey I created a setup file and installed on my desktop. As you said there are no .html files created. Instead there are two log file with .txt extension are created. The log file doesn't show me the messages ...like when i created a new folder and edited few files in other folder........these events were not recorded in the log file. Can you upload your updated code once again or can you email me to santu.kandhukuri@gmail.com
thanks
santosh
san
|
|
|
|
 |
|
 |
Hi,
I am using this utility to copy one file from one folder to another on different server where we are using load balancing. For example i have two folders: FolderA (on ServerA) and FolderB (on ServerB). One of my application sends a file to FolderA which is my path to watch and then instantly it copies over to FolderB which is my Destination. File name would be the same every time i send it to FolderA how ever it would have different content, I want to replace existing file with new one one and replace it on FolderB as well. Please advice.
Thanks
Ronnie
|
|
|
|
 |
|
 |
Hi prashant,
it is throwing internal windows error..
shiv
shivaraj
|
|
|
|
 |
|
 |
I have a problem relating to Windows Services and FileSystemWatcherClass of .NET.
I developed a windows service to monitor a specific folder on a server for changes and maintains its updated back up in another folder.
FileSystemWatcherClass is inherited to monitor and create mirror of a folder. It is available at http://www.codeproject.com/cs/files/directorymirror.asp?msg=1801877.
However, I found a limitation of this application. When copying large data (10 – 15 MB) it misses many events and only copies about half of the data. (This problem is also referred in the comments of the above article).
Possible cause of the problem:
When you copy or drop large amounts of data somewhere it can take several seconds for the system to write the data to the disk. The system cannot send feedback about the status of the operation (completed, failed, queued, etc) while it is performing it or while it is queued, and during this time other requests to the file system are queued by the system. This is what I think is the source of the problem: The FileSystemWatcher has no patience and throws an exception if it doesn’t get an IMMEDIATE response from the file system. So any big operation that takes a bit of time will end up throwing an exception and often but not always, cause the operation to abort. This class seems to be completely ignorant of how the windows file system works.
I found a solution to that on msdn, that says increase the INTERNALBUFFERSIZE. The Windows operating system notifies your component of file changes in a buffer created by the FileSystemWatcher. If there are many changes in a short time, the buffer can overflow. This causes the component to lose track of changes in the directory, and it will only provide blanket notification.
This solution resolved the problem somehow. I increased buffer to 64KB (default is 8192 bytes). This successfully copied data up to 35MB without missing a single file and suffices to my needs.
The problem is, when I integrated this into a Windows Service, it all failed to copy even 3 – 4 MB of Data. I have searching a lot but haven’t found the right solution yet.
I would be grateful if somebody could help me out with that. Thanks a lot for your patience of reading a long mail.
regards,
Fayyaz Khan Lodhi
fayyaz.lodhi@confiz.com
|
|
|
|
 |
|
 |
If you are trying to monitor a folder on a network drive, and attempting to access it using a mapped drive letter (eg t:\watchedFolder\) then this won't work when running as a service. You can't use mapped drive letters in a service, you must use the uri eg \\yourServername\...\watchedFolder\).
Robert Pocklington
netWealth
robert@netwealth.com.au
|
|
|
|
 |
|
 |
I have your project up and running ok but I have noticed that when I copy and paste files into a directory that is monitored, the service seems to be logging 3 changes in addition to the file creation, so in the log file I get :
8252110i.04.gif,C:\Test\dir1\image1.04.gif,Created,guestd,01/11/2006,15:31:03.5084857
8252110i.04.gif,C:\Test\dir1\image1.04.gif,Changed,guestd,01/11/2006,15:31:03.5241093
8252110i.04.gif,C:\Test\dir1\image1.04.gif,Changed,guestd,01/11/2006,15:31:03.5553565
8252110i.04.gif,C:\Test\dir1\image1.04.gif,Changed,guestd,01/11/2006,15:31:03.5866037
dir1,C:\Test\dir1,Changed,guestd,01/11/2006,15:31:03.6178509
Is there a way to get the service to ignore these extra events?
Dave
|
|
|
|
 |
|
 |
I can get the message when some.txt has changed,how can i get the content added?
|
|
|
|
 |
|
 |
When I open the solution it complains about not finding "testproject.csproj". It is not there. what gives?
|
|
|
|
 |
|
 |
Mine is also same problem. When I open the solution it complains about not finding "testproject.csproj". Can anyone reslove it???
|
|
|
|
 |
|
 |
My problem is to catch the user (window user) that modify a file . From the introduction of your article it seem's possible but actually the username displayed is the username of who started the watcher.
Vice
|
|
|
|
 |
|
 |
same problem - does anyone have a solution for it?? THX
|
|
|
|
 |
|
 |
does anybody know how I would go about getting the user account that altered\created the file?
|
|
|
|
 |
|
 |
This code does not reveal the username who has performed the operation. It will always return NT AUTHORIY\SYSTEM.
|
|
|
|
 |
|
 |
I haven't found a good way to do it either. You can see this information if you turn on file/folder auditing and monitor the security event log. But to use this info you would have to monitor the eventlog for changes and then try to correlate this with the filesystem changes and that sounds like a real pain to code.
|
|
|
|
 |
|
 |
the FileSystemWatcher can only watch for changes. Do you know how to get notified while a file is opened?
thanks.
|
|
|
|
 |