events problem

  • Thread starter Thread starter D.D.
  • Start date Start date
D

D.D.

Hi,

I made a console application that had to delete some files and
afterwards write to a log file which files were deleted. I wrote an
event that triggers every time a file was deleted so a line could be
written to the logfile.

Now my problem is that when I execute this console application with 2
files to delete there's nothing in my logfile. When I execute the same
application in debug mode with some breakpoints, it fills my logfile
with 2 lines (because 2 files where deleted).

When I test this with a 100 files then in debug mode and real mode it
writes correctly 100 lines to the logfile.

Why there is a difference in firing the delete event in debug mode and
real mode when using a only 2 files? Has it something to do with the
execution speed.
(with 2 files in real mode, the program has already been terminated
before the disk could write to the logfile, or is this event
asynchronous).

If someone could give me a reasonable explanation or a workaround.

greetz.
 
I suspect the buffer is not being flushed to the file, and that why the data
is not being saved to disk. I suggest (assuimg you are using FileStream or
Trace with File) you call Flush() method after each file delete to force the
stream to save data to disk.

Fitim Skenderi
 
Hi,

Used the Flush() method after every Delete.File(name of the file)
statement.
Still nothing. Moved the Flush() method before the Close() statement.
Same result, in real mode nothing was written to my logfile.
 
Back
Top