using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace MyProject
{
public partial class MyForm : Form
{
Process MyProcess;
public MyForm()
{
InitializeComponent();
}
private void MyForm_KeyPress(object sender, KeyPressEventArgs e)
{
switch (e.KeyChar)
{
case 'a':
this.MyPictureBox.Image = null;
this.MyProcess = new Process();
this.MyProcess.StartInfo =
new ProcessStartInfo("\"C:\\Program Files (x86)\\LilyPond\\usr\\bin\\lilypond.exe\"", "--png tmp.ly");
this.MyProcess.Start();
this.MyProcess.WaitForExit();
this.MyPictureBox.Image = new Bitmap("tmp.png");
break;
default:
break;
}
}
}
}
"C:\Program Files (x86)\LilyPond\usr\bin\lilypond.exe" --png tmp.ly
命令创建tmp.png
. 当我a
第一次按下键时,MyProcess 返回 0,但下一个 - 总是返回 1。我认为问题出在tmp.png
MyPictureBox 正在使用的覆盖文件中,但我不知道如何修复它。你可以帮帮我吗?