1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| public string str;
public string i;
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (str.Length > 0)
{
int max = 50;
string don;
//int nboucle = 0;
if (i < str.Length - (str.Length % 50))
{
don = str.Substring(i, 50);
serialPort1.Write(don);
i += 50;
//progressBar1.Value = (nboucle*100 / str.Length);
//toolStripStatusLabel1.Text = progressBar1.Value.ToString() + "%" + "Transférés...";
}
else
{
max = str.Length % 50;
don = str.Substring(i, max);
serialPort1.WriteLine(don);
toolStripStatusLabel1.Text = "Transfert Fini";
}
}
} |
Partager