【发布时间】:2015-07-29 12:53:00
【问题描述】:
我正在使用graphicmagic exe 使用命令提示符执行命令。我在我的应用程序根文件夹中添加了 graphicsmagic exe。我想执行这个 exe 并通过 c# 传递参数。这个怎么做?我试过下面的代码:
方法:1
Process proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = AppDomain.CurrentDomain.BaseDirectory + "\\gm1.3.5\\gm",
Arguments = "convert -define dpx:colorspace=rgb -define tiff:bits-per-sample=16 'D:\\Image\\FFv1\\dpx1\\1.dpx' 'D:\\Image\\FFv1\\tiff1\\1.tiff'",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
}
方法:2
Process proc = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = @"D:\Executable\Projects\MMF\gm1.3.5\gm";
startInfo.Arguments = "convert -define dpx:colorspace=rgb -define tiff:bits-per-sample=16 \"D:\\Image\\FFv1\\dpx1\\1.dpx\" \"D:\\Image\\FFv1\\tiff1\\1.tiff\"";
proc.StartInfo = startInfo;
proc.Start();
但这两个都不起作用。请提出一种执行exe文件和传递命令的方法。
【问题讨论】:
-
它们在哪些方面不起作用? (请记住,Web 应用程序以有限的权限和访问权限运行。)
-
其实我是用shell方法在vb.net中使用这个exe来转换图像的,它的转换。当我尝试使用 C# 进行转换时,它没有转换。
-
是否抛出异常?你能从这个过程中得到任何输出吗?
-
没有例外。但是图像没有在路径中转换。
-
如何在c#中调用exe并传递参数?像 vb.net 中的 shell
标签: c# shell web-applications command-line-arguments exe