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
command creates tmp.png
. When I press a
key first time, MyProcess returns 0, but next - returns 1 always. I think the problem is in overwritting file tmp.png
, which is using by MyPictureBox, but I have no idea how to repair it. Could you help me?