D
dhilip gopalan
Guest
I am trying to run a process in my code looping through each file and performing some task. Sometimes the EXE gets stuck when it runs across some files. And this doesn't move forward. If this kind of situation occurs how can I skip the files which is stuck in the process and save the file into a TXT file which has failed. And further move with the next file for processing. I tried to check it online and didn't get much help. Please suggest how can I get this done?
foreach (var file in files)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = exedir + "\\testing.exe",
Arguments = "-a -h -i -l " + file,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
using (Process exeProcess = Process.Start(processStartInfo ))
{
var line = string.Empty;
using (StreamReader streamReader = exeProcess.StandardOutput)
{
while (!streamReader.EndOfStream)
{
var content = streamReader.ReadLine();
// Doing some task here
}
}
exeProcess.WaitForExit(10000);
}
}
Continue reading...
foreach (var file in files)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = exedir + "\\testing.exe",
Arguments = "-a -h -i -l " + file,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
using (Process exeProcess = Process.Start(processStartInfo ))
{
var line = string.Empty;
using (StreamReader streamReader = exeProcess.StandardOutput)
{
while (!streamReader.EndOfStream)
{
var content = streamReader.ReadLine();
// Doing some task here
}
}
exeProcess.WaitForExit(10000);
}
}
Continue reading...