0
에서 실행할 때 나는 다음과 같습니다 배치 파일이 실패배치 파일을 실행할 때 작동하지만, 응용 프로그램
@echo off
REM Create the folder to put the converted files in
md PngConverted
REM Iterate all bitmap files
for /r %%F in (*.bmp) do (
REM Convert the files to PNG. Resize them so they are no bigger than 1300x1300
REM Also limit to 250 colors.
convert -resize 1300x1300 -colors 250 "%%~nF%%~xF" ".\PngConverted\%%~nF.png"
REM Output to the user that we completed this file.
echo converted %%~nF%%~xF to png
)
그것은 ImageMagick를 변환 및 이미지의 무리의 크기를 조정하는 데 사용합니다.
방금 두 번 클릭하면 작동합니다. 오류없이 실행되고 변환 된 이미지를 출력합니다.
그러나,이 같은 콘솔 응용 프로그램에 넣어려고 :
static void Main(string[] args)
{
// Run the batch file that will convert the files.
ExecuteCommand("ConvertImagesInCurrentFolder.bat");
// Pause so the user can see what happened.
Console.ReadLine();
}
static void ExecuteCommand(string command)
{
int exitCode;
ProcessStartInfo processInfo;
Process process;
processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
// *** Redirect the output ***
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
process = Process.Start(processInfo);
process.WaitForExit();
// *** Read the streams ***
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
exitCode = process.ExitCode;
Console.WriteLine("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output));
Console.WriteLine("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
Console.WriteLine("ExitCode: " + exitCode.ToString(), "ExecuteCommand");
process.Close();
}
그리고 오류 얻을 :에서이 작업을 실행할 때 나는이 오류를 얻을 것 왜
Invalid Parameter - 1300x1300
을 내 콘솔 응용 프로그램,하지만 명령 줄에서 실행할 때?
정확히 그랬습니다! 고맙습니다. – Vaccano