[英]How changing directories in Pandoc using C#?
How to set a directory and execute a file conversion in Pandoc using C#. 如何使用C# 在Pandoc中 设置目录并执行文件转换。
string processName = "pandoc.exe";
string arguments = @"cd C/Users/a/Desktop/ConvertFileApp/ConvertFileApp/bin/Debug/marcdovd "
+ "chapter1.markdown "
+ "chapter2.markdown "
+ "chapter3.markdown "
+ "title.txt "
+ "-o progit.epub";
var psi = new ProcessStartInfo
{
FileName = processName,
Arguments = arguments,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true
};
var process = new Process { StartInfo = psi };
process.Start();
this code does not work. 此代码不起作用。
You're calling the executable with the cd
command as an argument . 您正在使用
cd
命令作为参数调用可执行文件。 That's the equivalent of running the following on the command line: 这相当于在命令行上运行以下命令:
pandoc.exe cd C/Users/a/Desktop/ConvertFileApp/ConvertFileApp/bin/Debug/marcdovd chapter1.markdown chapter2.markdown chapter3.markdown title.txt -o progit.epub
While I'm not familiar with Pandoc, I imagine you actually want to do something like this: 虽然我对Pandoc并不熟悉,但我想您实际上想做这样的事情:
cd C:/Users/a/Desktop/ConvertFileApp/ConvertFileApp/bin/Debug/marcdovd
pandoc.exe chapter1.markdown chapter2.markdown chapter3.markdown title.txt -o progit.epub
To do this, remove the cd
command from your arguments and set the ProcessStartInfo.WorkingDirectory
property like so: 为此,请从参数中删除
cd
命令,并按如下所示设置ProcessStartInfo.WorkingDirectory
属性 :
string processName = "pandoc.exe";
string arguments = "chapter1.markdown "
+ "chapter2.markdown "
+ "chapter3.markdown "
+ "title.txt "
+ "-o progit.epub";
var psi = new ProcessStartInfo
{
FileName = processName,
Arguments = arguments,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true,
WorkingDirectory = @"C:/Users/a/Desktop/ConvertFileApp/ConvertFileApp/bin/Debug/marcdovd"
};
var process = new Process { StartInfo = psi };
process.Start();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.