I have this command line that someone helped me with:
type "\\NetworkDriveLocation\Folder\test.pdf"|find "pdf:Keywords"
I want to execute this in C# using System.Diagnostics.Process. When ran through cmd, it works as expected, but it doesn't seem to like the fact that I'm piping the output of the command into the find when running it through System.Diagnostics.Process. Here is the code so far:
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
process.StartInfo = startInfo;
startInfo.WorkingDirectory = importFileDirectoryInfo.FullName;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = $"/c type \"{fileInfo.FullName}\" | find \"pdf:Keywords\"";
process.Start();
var output = string.Empty;
while(!process.HasExited)
{
output += process.StandardOutput.ReadToEnd();
}
It basically exists immediately. If I remove: | find \"pdf:Keywords\"
, then it appends output. Copilot wasn't much help. I'm sure I'm just missing a syntax, but can't figure out what it is.