Code: Select all
private static string logFileName = "log.txt";
static int Main(string[] args)
{
try
{
if (args.Count() == 0)
{
Log("NO Arguments");
}
else
{
for (int i = 0; i < args.Length; i++) // Loop through array
{
string argument = args[i];
Log(i + " " + argument);
}
}
}
catch (Exception e)
{
Log(e.Message);
}
return 0;
}
private static void Log(string logText)
{
StreamWriter log;
if (!File.Exists(logFileName))
{
log = new StreamWriter(logFileName);
}
else
{
log = File.AppendText(logFileName);
}
log.WriteLine(DateTime.Now + " - " + logText);
log.Close();
}EDIT: I solved this. I didn't realize it was trying to write the log inside the sabnzbd directory instead of where the script file is located. I declared a full path for the log file and it worked.
