本文整理汇总了C#中System.Diagnostics.Process.Close方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.Process.Close方法的具体用法?C# System.Diagnostics.Process.Close怎么用?C# System.Diagnostics.Process.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Process
的用法示例。
在下文中一共展示了System.Diagnostics.Process.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CatchImg
/// <summary>
/// 生成FLV视频的缩略图
/// </summary>
/// <param name="vFileName">视频文件地址</param>
/// <param name="FlvImgSize">宽和高参数,如:240*180</param>
/// <returns></returns>
public static string CatchImg(string vFileName, string FlvImgSize, string Second)
{
if (!System.IO.File.Exists(HttpContext.Current.Server.MapPath(vFileName)))
return "";
try
{
string flv_img_p = vFileName.Substring(0, vFileName.Length - 4) + "_thumbs.jpg";
string Command = " -i \"" + HttpContext.Current.Server.MapPath(vFileName) + "\" -y -f image2 -ss " + Second + " -t 0.1 -s " + FlvImgSize + " \"" + HttpContext.Current.Server.MapPath(flv_img_p) + "\"";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"ffmpeg.exe";
p.StartInfo.Arguments = Command;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/bin/tools/");
//不创建进程窗口
p.StartInfo.CreateNoWindow = true;
p.Start();//启动线程
p.WaitForExit();//等待完成
p.Close();//关闭进程
p.Dispose();//释放资源
System.Threading.Thread.Sleep(4000);
//注意:图片截取成功后,数据由内存缓存写到磁盘需要时间较长,大概在3,4秒甚至更长;
if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(flv_img_p)))
{
return flv_img_p;
}
return "";
}
catch
{
return "";
}
}
示例2: CreateFromURL
/// <summary>
/// Convert Html page at a given URL to a PDF file using open-source tool wkhtml2pdf
/// </summary>
public static bool CreateFromURL(string url, string outputFilePath, bool hideBackground = false, int margin = 10)
{
var p = new System.Diagnostics.Process();
p.StartInfo.FileName = HttpContext.Current.Server.MapPath(@"~\wkhtmltopdf\wkhtmltopdf.exe");
var switches = String.Format("--print-media-type --margin-top {0}mm --margin-bottom {0}mm --margin-right {0}mm --margin-left {0}mm --page-size Letter --redirect-delay 100", margin);
if (hideBackground) switches += "--no-background ";
p.StartInfo.Arguments = switches + " " + url + " " + outputFilePath;
p.StartInfo.UseShellExecute = false; // needs to be false in order to redirect output
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true; // redirect all 3, as it should be all 3 or none
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath(@"~\wkhtmltopdf\");
p.Start();
// read the output here...
string output = p.StandardOutput.ReadToEnd();
// ...then wait n milliseconds for exit (as after exit, it can't read the output)
p.WaitForExit(60000);
// read the exit code, close process
int returnCode = p.ExitCode;
p.Close();
// if 0 or 2, it worked (not sure about other values, I want a better way to confirm this)
return (returnCode == 0 || returnCode == 2);
}
示例3: btnManualusuario_Click
private void btnManualusuario_Click(object sender, EventArgs e)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "C:/Users/Jessica/Desktop/proyecto1grupo1 unificado/proyecto1grupo1_Version4 admin&gestion&reportes unificados/proyecto1grupo1/bin/Debug/manualdeusuario.pdf";
proc.Start();
proc.Close();
}
示例4: ConvertFlv
/// <summary>
/// 视频格式转为Flv
/// </summary>
/// <param name="vFileName">原视频文件地址</param>
/// <param name="ExportName">生成后的Flv文件地址</param>
public bool ConvertFlv(string vFileName, string ExportName)
{
if ((!System.IO.File.Exists(ffmpegtool)) || (!System.IO.File.Exists(HttpContext.Current.Server.MapPath(vFileName))))
{
return false;
}
vFileName = HttpContext.Current.Server.MapPath(vFileName);
ExportName = HttpContext.Current.Server.MapPath(ExportName);
string Command = " -i \"" + vFileName + "\" -y -ab 32 -ar 22050 -b 800000 -s 480*360 \"" + ExportName + "\""; //Flv格式
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = ffmpegtool;
p.StartInfo.Arguments = Command;
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/tools/");
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
p.Dispose();
return true;
}
示例5: CreateRar
/// <summary>
///
/// </summary>
/// <param name="pSource">要压缩的文件夹</param>
/// <param name="pDestination">压缩后的rar完整名</param>
public void CreateRar(string pSource, string pDestination)
{
try
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "Winrar.exe";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.Arguments = " a -r -ep1 " + pDestination + " " + pSource;
proc.Start();
proc.WaitForExit();
if (proc.HasExited)
{
int iExitCode = proc.ExitCode;
if (iExitCode == 0)
{//压缩成功}
}
else
{
}
}
proc.Close();
}
catch (Exception ex)
{
}
}
示例6: Execute
public static string Execute(string command)
{
var p = new System.Diagnostics.Process();
//设定程序名
p.StartInfo.FileName = "cmd.exe";
//关闭Shell的使用
p.StartInfo.UseShellExecute = false;
//重定向标准输入
p.StartInfo.RedirectStandardInput = true;
//重定向标准输出
p.StartInfo.RedirectStandardOutput = true;
//重定向错误输出
p.StartInfo.RedirectStandardError = true;
//设置不显示窗口
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(command); //这里就可以输入你自己的命令
var str= p.StandardOutput.ReadLine();
p.Close();
return str;
}
示例7: callCmdSync
/// <summary>
/// 使用cmd环境执行命令,同步执行一句传入命令
/// </summary>
/// http://www.cnblogs.com/wucg/archive/2012/03/16/2399980.html
/// <param name="workDir"></param>
/// <param name="cmdStr"></param>
public static void callCmdSync(string workDir, string cmdStr)
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.EnableRaisingEvents = false;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;//true
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "cmd.exe"; //fileName;
p.StartInfo.WorkingDirectory = workDir;//@"E:\";
//p.StartInfo.Arguments = args;//传入bat的参数
p.StartInfo.LoadUserProfile = false;
p.Start();
//输出到命令行
p.StandardInput.WriteLine(cmdStr);
p.StandardInput.WriteLine("exit");
//捕获不到类似 dirxxx的错误信息
//string ret = p.StandardOutput.ReadToEnd(); //获取返回值
//LogOutput.logConsoleNow(ret);
/* 按行获取返回值 */
string line = p.StandardOutput.ReadLine();//每次读取一行
while (!p.StandardOutput.EndOfStream) {
if (line != string.Empty) {
LogOutput.logConsoleNow(line + " ");
}
line = p.StandardOutput.ReadLine();
}
p.WaitForExit();
p.Close();
LogOutput.logConsoleNow("--cmd over--");
}
示例8: GetScreenShot
public static void GetScreenShot(string path,string filename)
{
//string result = "";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = path + "\\adb.exe";
//要执行的程序名称
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
//可能接受来自调用程序的输入信息
p.StartInfo.RedirectStandardOutput = true;
//由调用程序获取输出信息
p.StartInfo.CreateNoWindow = true;
p.StartInfo.Arguments = "shell /system/bin/screencap -p /sdcard/" + filename;
//不显示程序窗口
p.Start();
//result += p.StandardOutput.ReadToEnd();
//p.BeginOutputReadLine();
p.WaitForExit();
while (p.ExitCode != 0)
{
//result += p.StandardOutput.ReadToEnd();
//Thread.Sleep(200);
}
p.Close();
return;
}
示例9: MovieMaking
public void MovieMaking(String name,int rate,int dig)
{
Mouse.OverrideCursor = Cursors.Wait;
String currentDirectory = System.IO.Directory.GetCurrentDirectory();
String imageSource = Images[0].Path;
imageSource = imageSource.Substring(0, imageSource.Length - (4+dig));
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = System.Environment.GetEnvironmentVariable("ComSpec");
//出力を読み取れるようにする
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = false;
//ウィンドウを表示しないようにする
p.StartInfo.CreateNoWindow = true;
//コマンドラインを指定("/c"は実行後閉じるために必要)
p.StartInfo.Arguments = @"/c cd " + currentDirectory + " &cores\\ffmpeg.exe -f image2 -r " + rate.ToString() + " -i " + imageSource + "%0" + dig.ToString() + "d.jpg -r " + rate.ToString() + " -an -vcodec libx264 -pix_fmt yuv420p " +name+ ".mp4";
//起動
p.Start();
//出力を読み取る
string results = p.StandardOutput.ReadToEnd();
//プロセス終了まで待機する
//WaitForExitはReadToEndの後である必要がある
//(親プロセス、子プロセスでブロック防止のため)
p.WaitForExit();
p.Close();
Mouse.OverrideCursor = null;
}
示例10: ApplyPatch
public static void ApplyPatch(FpuSegment seg)
{
Process p=new Process();
p.StartInfo.FileName="nasm.exe";
p.StartInfo.Arguments="out.txt";
p.StartInfo.UseShellExecute=false;
p.StartInfo.CreateNoWindow=true;
p.Start();
p.WaitForExit();
p.Close();
FileInfo fi=new FileInfo("out");
if(fi.Length==0) throw new OptimizationException("Patcher: Code generator produced uncompilable code");
ArrayList code=new ArrayList();
for(int i=0;i<seg.Pre.Length;i++) {
code.AddRange(HexToString(seg.Pre[i].code));
}
code.AddRange(Program.ReadFileBytes("out"));
for(int i=0;i<seg.Post.Length;i++) {
code.AddRange(HexToString(seg.Post[i].code));
}
if(code.Count>seg.End-seg.Start) throw new OptimizationException("Patcher: Patch to big to fit into code");
/*if(Program.TestPatches) {
TestPatch(seg); //TESTPATCH CALL
}*/
if(Program.Benchmark) {
Benchmark(seg); //BENCHMARK CALL!!!!!!!!!!!!!!!!!!!!!!!! <---------------- OVER HERE
}
byte[] Code=new byte[seg.End-seg.Start];
code.CopyTo(Code);
for(int i=code.Count;i<(seg.End-seg.Start);i++) {
Code[i]=144; //Fill the rest of the code up with nop's
}
long a=(seg.End-seg.Start)-code.Count;
if(a>255) {
throw new OptimizationException("Patcher: Patch end address out of range of a short jump");
} else if(a>2) {
Code[code.Count]=235;
Code[code.Count+1]=(byte)(a-2);
}
if(Program.Restrict) {
if(PatchCount<Program.FirstPatch||PatchCount>Program.LastPatch) {
PatchCount++;
throw new OptimizationException("Patcher: Patch restricted");
}
PatchCount++;
}
#if emitpatch
FileStream fs2=File.Create("emittedpatch.patch",4096);
BinaryWriter bw=new BinaryWriter(fs2);
bw.Write(seg.Start);
bw.Write(Code.Length);
bw.Write(Code,0,Code.Length);
bw.Close();
#endif
FileStream fs=File.Open("code",FileMode.Open);
fs.Position=seg.Start;
fs.Write(Code,0,Code.Length);
fs.Close();
}
示例11: PDF2SWF
/// <summary>
/// PDF格式转为SWF
/// </summary>
/// <param name="pdfPath">PDF文件地址</param>
/// <param name="swfPath">生成后的SWF文件地址</param>
/// <param name="beginpage">转换开始页</param>
/// <param name="endpage">转换结束页</param>
private static bool PDF2SWF(string pdfPath, string swfPath, int beginpage, int endpage, int photoQuality)
{
string exe = HttpContext.Current.Server.MapPath("~/Bin/tools/pdf2swf-0.9.1.exe");
pdfPath = HttpContext.Current.Server.MapPath(pdfPath);
swfPath = HttpContext.Current.Server.MapPath(swfPath);
if (!System.IO.File.Exists(exe) || !System.IO.File.Exists(pdfPath) || System.IO.File.Exists(swfPath))
{
return false;
}
StringBuilder sb = new StringBuilder();
sb.Append(" \"" + pdfPath + "\"");
sb.Append(" -o \"" + swfPath + "\"");
sb.Append(" -s flashversion=9");
if (endpage > GetPageCount(pdfPath)) endpage = GetPageCount(pdfPath);
sb.Append(" -p " + "\"" + beginpage + "" + "-" + endpage + "\"");
sb.Append(" -j " + photoQuality);
string Command = sb.ToString();
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = exe;
p.StartInfo.Arguments = Command;
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/Bin/");
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
p.Dispose();
return true;
}
示例12: setupPortForwarding
private void setupPortForwarding(int port) {
string adbCommand = string.Format("adb forward tcp:{0} tcp:{0}", port);
System.Diagnostics.Process myProcess;
#if UNITY_EDITOR_WIN
string cmd = @"/k " + adbCommand + " & exit";
Debug.Log ("Executing: [" + cmd + "]");
myProcess = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo myProcessStartInfo =
new System.Diagnostics.ProcessStartInfo("CMD.exe", cmd);
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.CreateNoWindow = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
#else
Debug.LogFormat("Trying to launch adb: {0}", adbCommand);
myProcess = System.Diagnostics.Process.Start("bash", string.Format("-l -c \"{0}\"",
adbCommand));
#endif
myProcess.WaitForExit();
int exitCode = myProcess.ExitCode;
myProcess.Close();
if (exitCode == 0) {
Debug.LogFormat("adb process succeeded (exit code 0).");
} else {
Debug.LogErrorFormat("adb process FAILED (exit code {0}). Check that the Android SDK " +
"is installed and that the adb command is in your PATH environment variable.",
exitCode);
}
}
示例13: CheckEpub
//CheckEpubを実施、Output/Errorを表示する
public void CheckEpub()
{
//EPUBチェック実施中パネルを表示する
var checkingDlg = new EpubCheckingDialog();
checkingDlg.Show();
var p = new System.Diagnostics.Process();
//実行ファイル
p.StartInfo.FileName = javaPath;
//引数
var args = "-jar "
+ "\""+ epubCheckPath + "\" "
+" \"" + epubPath + "\"";
p.StartInfo.Arguments = args;
//出力とエラーをストリームに書き込むようにする
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
//OutputDataReceivedとErrorDataReceivedイベントハンドラを追加
p.OutputDataReceived += OutputDataReceived;
p.ErrorDataReceived += ErrorDataReceived;
p.StartInfo.RedirectStandardInput = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
var resultDlg = new EpubCheckResultDialog();
//Outputをコピーする
foreach (var output in outputLines)
{
resultDlg.outputTextBox.Text += (output + "\n");
}
//Errorをコピーする
if (errorLines.Count> 1)
{
foreach (var error in errorLines)
{
resultDlg.errorTextBox.Text += (error + "\n");
}
}
else
{
resultDlg.errorTextBox.Text = "エラーはありませんでした。";
}
checkingDlg.Close();
resultDlg.ShowDialog();
}
示例14: Read
/// <summary>
/// 読み取り開始
/// </summary>
public void Read()
{
Console.WriteLine("FelicaReader::Read() - start");
// プロセスオブジェクトを生成
System.Diagnostics.Process p = new System.Diagnostics.Process();
// 実行ファイルを指定
p.StartInfo.FileName = this.tagtool;
// シェルコマンドを無効に
p.StartInfo.UseShellExecute = false;
// 入力をリダイレクト
p.StartInfo.RedirectStandardInput = true;
// 出力をリダイレクト
p.StartInfo.RedirectStandardOutput = true;
// OutputDataReceivedイベントハンドラを追加
p.OutputDataReceived += OutputDataReceivedHandler;
// プロセスを実行
p.Start();
// 非同期で出力の読み取りを開始
p.BeginOutputReadLine();
// 入力を行う為のストリームライターとプロセスの標準入力をリンク
System.IO.StreamWriter myStreamWriter = p.StandardInput;
myStreamWriter.Close();
p.WaitForExit();
p.Close();
Console.WriteLine("FelicaReader::Read() - end");
}
示例15: convert
public String convert(string pdfdoc)
{
String command = "";
try
{
String output = "";
command = configManager.getConfig("cmd.conversion.splitpdffile");
command = command.Replace("{path.pdf}", configManager.getConfig("path.pdf"));
command = command.Replace("{path.swf}", configManager.getConfig("path.swf"));
command = command.Replace("{pdffile}", pdfdoc);
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = command.Substring(0, command.IndexOf(".exe") + 5);
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
proc.StartInfo.CreateNoWindow = true;
//proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.Arguments = command.Substring(command.IndexOf(".exe") + 5);
if (proc.Start())
{
proc.WaitForExit();
proc.Close();
return "[OK]";
}
else
return "[Error converting splitting PDF, please check your configuration]";
}
catch (Exception ex)
{
return "[" + ex.Message + "]";
}
}