المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : File Size Monitoring [modified]



C# Programming
07-16-2009, 08:00 PM
Hi,

Firstly, I am trying to create a quick hardcoded application to monitor the filesize of any file using FileSystemWatcher.

My problem is that the file I am trying to monitor is ALWAYS in use. This is expected because it is a data file that is always open by another application. I would like to see how the data file size changes over time.

If I try to access the properties of this file while it is in use, I get a file in use exception, which is kind of expected.

The event is triggered by a filesize change and it works if I do not try to access the file to get the filesize. But then this application would be meaningless.

To get the filesize, I am using the FileInfo class.

Does anyone know some workaround or how I can avoid this problem? (Without actually closing the data file) No need to go into a lot of detail, I'll google it but I could just use a hint though, if it's possible http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif

Maybe I could somehow check the filesize on a system level? (i.e. the file size that windows sees and displays on rightclick -> properties instead of actually accessing it?)

Thanks,
See_Sharp

modified on Thursday, July 16, 2009 11:56 AM