Click here to Skip to main content
15,879,072 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Dear,

I'm using the enterprise library 5.0 in order to register the exception thrown into a log file in a windows WPF application.
ExceptionPolicy.HandleException(exception, "ExceptionPolicy");

And also I have added the functionality in order to delete the file on click.
File.Delete(logFilePath);

Scenario:


    1. If the log file is full but no exception has been raised:
      >> The file is deleted smoothly.
    2. If the log file is full and an exception is raised:
      >> An additional exception is raised informing that the file could not be deleted because it is used by another process.



EDIT ================

I have found the solution, all I have to do is:

Add reference to the enterprise Logging DLL:

C#
using Microsoft.Practices.EnterpriseLibrary.Logging;


And then add Logger.Writer.Dispose(); before File.Delete(logFilePath):

C#
[...]
Logger.Writer.Dispose();
File.Delete(logFilePath);
[...].
Posted
Updated 30-Dec-10 23:36pm
v2

1 solution

Answered only to remove from unanswered list...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900