Changed logging path to subdirectory of current install lib

This commit is contained in:
2021-03-02 22:59:13 +01:00
parent fe65037c76
commit 577aac2c4a

View File

@ -9,6 +9,8 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Diagnostics;
namespace StockDal
{
@ -72,7 +74,14 @@ namespace StockDal
private void SaveLogging()
{
var output = JsonConvert.SerializeObject(DumpObjects, Formatting.Indented);
File.WriteAllText($"D:\\TimCoDemos\\DemoLogs\\Log{DateTime.Now.ToShortDateString()}.txt",output);
Assembly assem = typeof(StockMarketRepository).Assembly;
var programPath = assem.Location.Substring(0, assem.Location.LastIndexOf("\\"));
var logPath = new DirectoryInfo(programPath + "\\Loggings");
if (!logPath.Exists)
{
logPath.Create();
}
File.WriteAllText($"{programPath}\\Loggings\\Log{DateTime.Now.ToShortDateString()}.txt", output);
}
private void AddValueToListRow(int pos, string value)