Not getting the .txt output after running a process
Im trying to log all the text that is output from a program into a txt file, but after its run successfully it does not seem to generate the .txt file as specified, if it is generated i dont know where it is ending up.
Im running the process like this:
the entire program is completing and exiting, the process is outputting the correct data im requesting with the command, but as said there is no .txt file in the specified location (it should be in the same folder as the input file). its as if its entirely ignoring the
>> {2}_Pdal_PointLog.txt
section of the command. I have also double checked that the .txt path is correct as im logging the final command so i can see it.
i have both tried using the .exe i need directly and cmd then calling the .exe with arguments from that but that does not seem to make a difference.3 Replies
the
>
to redirect output is part of the shell, not something you can do via Process
you'll need to capture the output yourself, and write it to a file using C#
hint: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.standardoutput?view=net-9.0#system-diagnostics-process-standardoutputOr turn UseShellExecute to true.
Which isn't always guarenteed to work.
That means File Explorer, not a terminal shell.
The word "shell" in this context (UseShellExecute) refers to a graphical shell (similar to the Windows shell) rather than command shells (for example, bash or sh) and lets users launch graphical applications or open documents.https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-diagnostics-processstartinfo-useshellexecute