 |
|
 |
I found it useful to add the following code to FileContentsControl.cs in the UpdateFileInfo() Method to avoid reading and processing initial text that will be discarded:
sr = new System.IO.StreamReader(fs);
if (fs.Length > MAX_SIZE) { if (fs.CanSeek) { fs.Seek(-MAX_SIZE, SeekOrigin.End); string dummy = sr.ReadLine(); } }
string contents = sr.ReadToEnd();
and then add the following to the class FileContentsControl public const long MAX_SIZE = 250000;
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
hi..
any idea on how to create a file watcher for fat file system (win9x/me).
thanks
saint
-- modified at 3:02 Monday 5th March, 2007
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Dear i want to change the location of the window like 1-the dockable window show at location (x=0,y=100) 2-change the size of the window (width=250,height=300)
plz reply me soon. Thanks in advance
Ranjeet Singh
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
How would one go about adding the ability to do a keyword search on the latest additions to a changed log file and then fire off an email for a keyword match ?
BitShift
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Here is an idea for an enhancement if you're interested:
Since most log files are text based, a fixed point font might show better, even an option to choose your own font wouldn't be too difficult.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi
I've been using the FileSystemWatcher to check for new files in a folder and when found I load the contents into a database and move the file elsewhere.
However, Ive just found out that if I copy the files from my machine to the server (where the service is running) via a VPN the service detects a new file and tries to process it, but the file hasnt fully copied yet so an error is eventually raised.
Is there a way to tell the systemWatcher to wait until the file has fully copied or a way of checking if any locks excess on the file.
Thanks for any help
Darren Rhymer
|
| Sign In·View Thread·PermaLink | 3.00/5 |
|
|
|
 |
|
 |
Very nice one!
I added a static variable, say counter, and added counter++ inside the fileSystemWatcher_Changed event handler, I observed that whenever I modified one loaded file, the counter increased by 3 not 1. If I write an info to a log file using sw.WriteLine(strFileName + " " + "Changed at " + DateTime.Now); then 3 entries with same time stamp will be written.
This is certainly not your bug, but I would like to know what's going on here, so I can log one entry per change. Hope you can give me some help.
Thanks in advance, J.L
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi J.L,
Sorry for the slow reply.
Have a look at this documentation:
WatcherChangeTypes Enumeration[^]
I think there is probably three changes for the following:
The change of a file or folder. The types of changes include: changes to size, attributes, security settings, last write, and last access time.
That's just a guess, but possibly they are being modified separately and result in 3 events?
Also look at the remarks from this part of the documentation:
FileSystemWatcher.Changed Event[^]
They don't say explicitly how many events to expect, but that there may be more than one.
Take care, Michael
Michael Kennedy Partner, Software Engineer United Binary, LLC
Index of my code project articles [^]
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
user can define groups that each group may hold as many files as they want. and when a group is loaded, all files within that group is being watched.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Chenhuisheng,
chenhuisheng wrote: user can define groups that each group may hold as many files as they want. and when a group is loaded, all files within that group is being watched.
How is this different from the "Load Group" / "Save Group" feature I added in the latest version?
Is it possible that you're referring to an older version which didn't have that feature?
Thanks, Michael
Michael Kennedy Partner, Software Engineer United Binary, LLC [^]
Index of my code project articles
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Nice tool, helps me in my current work.
I found one problem: when watching long files which change frequently, the program freezes and does not refresh. I suspect that's because refreshing the FileContents control (which includes opening the file, reading its whole contents and putting it into the window) takes longer than how fast the changes come, so the FileChanged events queue gets overloaded.
To resolve this, I tried to update the FileContentsCotrol only if the file is really changed. I added private DateTime updateTime; to the FileControl member variables, initialized that in the Initialize method: updateTime = System.IO.File.GetLastWriteTime(file); and modified the fileSystemWatcher_Changed method:
{ DateTime upd = System.IO.File.GetLastWriteTime(filename); if(upd>updateTime) { updateTime = upd; fileStatisticsControl.UpdateFileInfo(filename); fileContentsControl.UpdateFileInfo(filename); Fire_FileChanged(filename); } }
This works for me well.
LiborV
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi LiborV,
Thanks for the tip. I was concerned about very large files and very frequently changing large files when I first wrote this application. But I didn't have time to address those issues and still get this article done.
I'll try to get better support for large files in the next version. Your code will certainly be helpful for that. It's too bad that your message was posted just one day after I updated the application or I would have added better large file support to the current version.
Thanks for the feedback.
Regards, Michael
Michael Kennedy Partner, Software Engineer United Binary, LLC [^]
Index of my code project articles
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
There is one problem - you cannot use your tool for IIS log files. Why? The reason is IIS log files change by chunks - it means by 64 KByte of spaces. IIS add 64KB of spaces to log file and when it writes data to log file it simple replace spaces by data characters. More, it changes file attributes only when add new 64 kbytes. This only your chance get Change event for this file. So, you should create feature for timer reload or something similar. Except it - very nice tool. Best Regards,
Yuri Gorobets http://www.dotnetjunkies.com/weblog/removable thoughts
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Yuri,
Thanks.
You can use this program for IIS log files. It's just that IIS buffers its output, so not every single request will generate a change in the log file. It's not that the program can't detect the changes in the file. It's just that IIS won't change the file every time. This is probably an important feature for sites that have very heavy load.
I tried the utility out on an IIS log from IIS 5.0 and it took something like 10 requests for that log to update. I don't know how this varies from site to site. I imagine that it does somewhat though since you can change the logging contents and options in IIS.
Take care, Michael
Michael Kennedy Partner, Software Engineer United Binary, LLC [^]
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I was trying to use your program to monitor my IIS FTP server logs. I have an application that will tell a device to FTP firmware from my machine, and I need to see if the FTP was successful or not in real time. The simple FTP transactions that I am doing does not generate a whole lot of logging data, so it is not enough to push the buffer limit to write to the log file. Maybe IIS has a registry setting or something that I can force it to flush more often. I tried selecting more logging options in IIS to "pollute" the log file with verbose data, but that still does not fill the buffers enough.
Needless to say, when your tool monitors a log file that gets flushed after each entry, it works great!!!
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
Nice program.
Just notice that the tracetool project in codeproject does the same: http://www.codeproject.com/csharp/TraceTool.asp
Tracetool can also display the outputdebugstring window and provide a framework (for dot net, delphi and java) for powerfull traces
Thierry
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Thierry,
Thanks. That's an interesting program you have there. It looks to be on an entirely different scale than this simple utility.
Take care, Michael
Michael Kennedy Partner, Software Engineer United Binary, LLC [^]
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi there,
very nice. 
I have one observation, when a file is initially opened, the view does not scroll to the end; as you correctly pointed out modifications are usually at the end of the file, hence the most recently added information is at the end too. It probably would be better to open and scroll to the end of the file.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
Thanks. That's a good idea. I guess that thinking does apply to the files you open up just the same as when they are updated. 
That's another one for the updates that I'll put in there when/if an update is released.
Take care, Michael
Michael Kennedy Partner, Software Engineer United Binary, LLC [^]
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
|
 |
|
 |
Funny a few weeks ago I coded a log file viewer too. I think yours is cooler, I had only about an hour for mine...
A few things which you could think about...in order to make this one just a little better. What about transparency (I put a little slider in the status bar...doesn't look nice but works gracefully ),always on top and tray icon support. I found this very nice when logged websites and had no multi-monitor environment. I know it's a matter of minutes to put it into your source...just suggestions no criticism 
Anyway nice tool!
cu
Dennis
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Dennis,
Thanks, I'm glad you liked it. Those are some good suggestions. I especially like the tray icon support. Maybe it could use the notification balloons when a file changes. If I update the program I'll try to get that in there.
Take care, Michael
Michael Kennedy Partner, Software Engineer United Binary, LLC [^]
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |