0% found this document useful (0 votes)
22 views1 page

Using Using Using Using Using Using Using Using Using Using Using Using Using Using Namespace Public Partial Class Public

This document contains code for a Windows Forms application that uses Bluetooth to discover nearby Bluetooth devices, display them in a list view, and send a selected file to a selected device via OBEX. When a button is clicked, it clears the list view and uses the BluetoothClient to discover nearby Bluetooth devices, adding their names, addresses, and other details to the list view. When another button is clicked, it opens a file dialog, constructs a URI for the selected device in the list using its address, creates an ObexWebRequest to that URI with the selected file, and sends the file.

Uploaded by

mus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

Using Using Using Using Using Using Using Using Using Using Using Using Using Using Namespace Public Partial Class Public

This document contains code for a Windows Forms application that uses Bluetooth to discover nearby Bluetooth devices, display them in a list view, and send a selected file to a selected device via OBEX. When a button is clicked, it clears the list view and uses the BluetoothClient to discover nearby Bluetooth devices, adding their names, addresses, and other details to the list view. When another button is clicked, it opens a file dialog, constructs a URI for the selected device in the list using its address, creates an ObexWebRequest to that URI with the selected file, and sends the file.

Uploaded by

mus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

...dowsFormsApplication7\WindowsFormsApplication7\Form1.

cs 1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using InTheHand;
using InTheHand.Net;
using InTheHand.Net.Sockets;
using System.IO;
using System.IO.Ports;

namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
listView1.Items.Clear();
BluetoothClient dc = new BluetoothClient();
BluetoothDeviceInfo[] d = dc.DiscoverDevices();
for (int i = 0; i < d.Length; i++)
{
ListViewItem lv = new ListViewItem();
lv.SubItems[0].Text = d[i].DeviceName;
lv.SubItems.Add(d[i].DeviceAddress.ToString());
lv.SubItems.Add(d[i].DeviceAddress.Nap.ToString());
lv.SubItems.Add(d[i].DeviceAddress.Sap.ToString());

listView1.Items.Add(lv);
}
}

private void button2_Click(object sender, EventArgs e)


{
openFileDialog1.ShowDialog();
Uri u = new Uri("obex://" + listView1.SelectedItems[0].SubItems
[1].Text + "/" + Path.GetFileName(openFileDialog1.FileName));
ObexWebRequest s = new ObexWebRequest(u);
s.ReadFile(openFileDialog1.FileName);
s.GetResponse();
}
}
}

You might also like