Log file without explicit directory path causes Exception
IvanPizhenko opened this issue · 3 comments
IvanPizhenko commented
I have following in the BDA config file:
LandisData "Base BDA"
...
LogFile output_BDA_log.csv
And this causes me an error:
Internal error occurred within the program:
Path cannot be the empty string or all whitespace.
Parameter name: path
Stack trace:
at System.IO.Directory.CreateDirectory(String path)
at Landis.Extension.BaseBDA.MetadataHandler.InitializeMetadata(Int32 Timestep, String severityMapFileName, String srdMapFileName, String nrdMapFileName, String logFileName, IEnumerable`1 manyAgentParameters, ICore mCore)
at Landis.Extension.BaseBDA.PlugIn.Initialize()
at Landis.Model.InitExtensions(ExtensionMain[] extensions)
at Landis.Model.Run(String scenarioPath, IUserInterface ui)
at Landis.App.Main(String[] args) in D:\CGAProjects\Rob\LANDIS_FINAL\GitHubRepo\Core-Model-v7\Tool-Console\src\App.cs:line 99
I think this line of code causes the issue (in the MetadataHandler.cs):
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(logFileName));
if System.IO.Path.GetDirectoryName(logFileName)
just returns empty string or all whitespaces, the directory should not be created.
IvanPizhenko commented
I can submit PR that fixes this.
IvanPizhenko commented
I've also found a workaround, it is use .\logfile.txt
instead of just logfile.txt
, but still I just can submit a small fix for this.
IvanPizhenko commented
Please look at PR #9