How to enter the ApplicationData user folder by registering in the corporate library?

I use MS EnterpriseLibrary.Logging and works fine, but the log file is placed in the executable directory of the program.

How do I get it to put my log files in a separate userData folder of the user?

The folder I'm talking about is the one you call by calling:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
+3
source share
1 answer

You should be able to use environment variables in your file path. I find that Environment.SpecialFolder.ApplicationDataequivalent %APPDATA%.

, _: % APPDATA%\MyApplication\Logs\trace.log , .

:

  <add fileName="%APPDATA%\MyApplication\Logs\trace.log" header=""
    footer="" formatter="Text Formatter"     
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"
    traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"
    name="Flat File Destination" />
+6

Source: https://habr.com/ru/post/1742456/


All Articles