In a C# application, I need to use the curl command. I am using this code:
using (Process myProcess = new Process())
{
int miIntIntervaloActualizacion = GestorConfiguracion.GetIntervaloActualizacion();
string miStrUrl = GestorConfiguracion.GetUrl();
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.FileName = "curl";
myProcess.StartInfo.Arguments = $"--output index.html --url {miStrUrl}";
myProcess.StartInfo.CreateNoWindow = false;
myProcess.Start();
_logger.LogInformation($"IP actualizada en: {DateTime.Now}.");
await Task.Delay(miIntIntervaloActualizacion, stoppingToken);
}
I get the URL from a xml configuration file. This is not the problem.
In the parameter of the command, I have set the output, a html. If I run this command in a command line console, it contains "OK" if the command is successful, but it creates a html that I don't want to create in my application.
So I would like to know if there are some way to get the result of the curl command to know if it is successful or not.
Thanks.