Transfer Files Over Bluetooth Devices



In this article we will see how to transfer data on Pc, Pocket-Pc and Mobiles etc… via Bluetooth. You can find out so many sources on Actually I also got this source from this website only but it’s was raising some security issues. In this article I have modify some code.


Transferring files over LAN from one PC to another PC we can use some Remoting concept of .Net but for transferring file on Bluetooth enabled devices is not like .Net Remoting. Here we will see how to send files over various Bluetooth enabled devices.


For doing our task first we have to download the .dll files from Download this dll’s and Add reference to those dll’s to your project.

This .dll’s will provide all functionality which we want to complete all our task ex. Searching for Bluetooth devices, View their MAC ,Send the data etc…

Follow the step given bellow to complete our task.


Download InTheHand.dll from above link.


Start new Windows Application and add the reference to this .dll file. Design your UI like given bellow.


First import the namespace from the referenced .dll’s like bellow.

using InTheHand.Net;

using InTheHand.IO.Ports;

using InTheHand.Net.Bluetooth;

using InTheHand.Net.Forms;


In declaration section create instance of BluetoothAddress class which is present in InTheHand namespace of referenced dll.

InTheHand.Net.BluetoothAddress[] address_array = new BluetoothAddress[1000];

private Thread thrSend;


In btnDescover click event write the following code to discover the Bluetooth devices around us. Here we are creating the instance of Bluetoothclient Class present in InTheHand namespace of referenced dll.

InTheHand.Net.Sockets.BluetoothClient bc = new InTheHand.Net.Sockets.BluetoothClient();

InTheHand.Net.Sockets.BluetoothDeviceInfo[] array = bc.DiscoverDevices();

for (int i = 0; i < array.Length; i++)


this.address_array[i] = array[i].DeviceAddress;




For viewing the MAC,NAP and SAP address of selected bluetooth device write the folowing code in GetMAC_Click event for getting various address of Bluetooth device.

if (this.lstDevices.SelectedIndex == -1)


MessageBox.Show(“Please select a device.”);



int index = this.lstDevices.SelectedIndex;

string mac = this.address_array[index].ToString();

string nap = this.address_array[index].Nap.ToString();

string sap = this.address_array[index].Sap.ToString();

lblmac.Text = “MAC : ” + mac.ToString();

lblnap.Text = “NAP :” + nap.ToString();

lblsap.Text = “SAP :” + sap.ToString();


For sending file to Bluetooth Device write the following code in Send file_Click event to send the file.

this.thrSend = new Thread(new ThreadStart(sendfile));



The above code will start only the thread for sending file but you have to write the method which will do actual work of sending file. Write the method sendfile as bellow.

private void sendfile()


SelectBluetoothDeviceDialog dialog = new SelectBluetoothDeviceDialog();

dialog.ShowAuthenticated = true;

dialog.ShowRemembered = true;

dialog.ShowUnknown = true;

OpenFileDialog ofd = new OpenFileDialog();

ofd.Title = “Select File”;

ofd.Filter = “All Files (*.*)|.*”;

if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)


if (ofd.ShowDialog() == DialogResult.OK)


Cursor.Current = Cursors.WaitCursor;

System.Uri uri = new Uri(“obex://” + dialog.SelectedDevice.ToString() + “/” + ofd.FileName);

ObexWebRequest request = new ObexWebRequest(uri);


ObexWebResponse response = (ObexWebResponse)request.GetResponse();



Cursor.Current = Cursors.Default;




MessageBox.Show(“File Not Selected”);





MessageBox.Show(“Device Not Selected”);



In above method you can find ObexRequest and Response object to transfer the object from our application to bluetooth device.


In such easy manner only we can send files over various Bluetooth enabled devices.

11 responses to “BLUETOOTH DEVICE

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s