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 33 34 35 36 37 38 39 40 41 42 43 44 45
|
private void btnSendFile_Click(object sender, EventArgs e)
{
/*if (this.lstDevices.SelectedIndex == -1)
{
MessageBox.Show("Selectionner un mobile s'il vous plait.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}*/
//lstDevices.SetSelected(0, true);
try
{
for (int x = 0; x <= lstDevices.Items.Count; x++)
{
lstDevices.SetSelected(x, true);
MessageBox.Show("Mobile : " + lstDevices.SelectedItem.ToString(), " Transmission des Messages: ", MessageBoxButtons.OK, MessageBoxIcon.Information );
Selected = this.lstDevices.SelectedIndex;
this.thrSend = new Thread(new ThreadStart(sendfile));
this.thrSend.Start();
Thread.Sleep(5000);
}
}
catch
{
MessageBox.Show(" Liste des mobiles parcourus. "," Action Terminee ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void sendfile()
{
lock (this)
{
int index = Selected;
InTheHand.Net.BluetoothAddress address = this.address_array[index];
System.Uri uri = new Uri("obex://" + address.ToString() + "/" + "bluetooth_red.png");
ObexWebRequest request = new ObexWebRequest(uri);
request.ReadFile("C:\\Users\\dolnar\\Documents\\Visual Studio 2010\\Projects\\bluetoothPoc\\BluetoothPoC\\BluetoothPoC\\bin\\bluetooth_red.png");
ObexWebResponse response = (ObexWebResponse)request.GetResponse();
response.Close();
}
} |
Partager