Horje
c# create log file Code Example
c# create log file
From the performance point of view your solution is not optimal. Every time you add another log entry with +=, the whole string is copied to another place in memory. I would recommend using StringBuilder instead:

StringBuilder sb = new StringBuilder();
...
sb.Append("log something");

...
// flush every 20 seconds as you do it
File.AppendAllText(filePath+"log.txt", sb.ToString());
sb.Clear();
By the way your timer event is probably executed on another thread. So you may want to use a mutex when accessing your sb object.

Another thing to consider is what happens to the log entries that were added within the last 20 seconds of the execution. You probably want to flush your string to the file right before the app exits.




Csharp

Related
unity rb.addexplosionforce 2d Code Example unity rb.addexplosionforce 2d Code Example
c# update value in a json file Code Example c# update value in a json file Code Example
C# xamaring form change text on label Code Example C# xamaring form change text on label Code Example
c# listview add item Code Example c# listview add item Code Example
c# list remove by index Code Example c# list remove by index Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10