Fix missing logfile

This commit is contained in:
2025-03-25 22:28:39 -04:00
parent 5cdc726b2f
commit ca98ebfc74
2 changed files with 96 additions and 64 deletions

View File

@@ -77,6 +77,7 @@ namespace MarketData.Utils
DateTime date=javascriptEpoch+timespan;
return date;
}
public static void RemoveLogFiles(String strFolder=null)
{
if(null==strFolder)strFolder=Directory.GetCurrentDirectory();
@@ -94,6 +95,27 @@ namespace MarketData.Utils
catch(Exception){;}
}
}
public static void RemoveLogFilesExcept(String exceptFile,String strFolder=null)
{
if(null==strFolder)strFolder=Directory.GetCurrentDirectory();
String[] logFiles=Directory.GetFiles(strFolder);
if(null==logFiles || 0==logFiles.Length)return;
logFiles=logFiles
.Where(x => x.EndsWith(".log",StringComparison.InvariantCultureIgnoreCase) &&
!x.Equals(exceptFile,StringComparison.InvariantCultureIgnoreCase)).ToArray<String>();
if(null==logFiles || 0==logFiles.Length)return;
foreach(String logFile in logFiles)
{
try
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Removing {0}",logFile));
File.Delete(logFile);
}
catch(Exception){;}
}
}
public static String Pad(string str, char filler, int length)
{
int stringLength = str.Length;