Hello
I have searched through forum threads and cannot find information why I get a bad request when I use the sample code submitted with in the hand download.
I have version 1.6 of In the hand.
When I run the sample: ObjectPushApplication it works to send files to a bluetooth device but with the same code I get this bad request. I don't understand why at all. The dialog box to choose device works and I get the device address. The sample code is written in VS2005 but I also have an application, by Glarks, written in VisualBasic, VS2003 and it works.
Here is the code I have:
using
System;
using
System.Drawing;
using
System.Collections;
using
System.Windows.Forms;
using
System.Data;
using
System.Net;
using
System.Net.Sockets;
using
System.IO;
using
InTheHand.Net;
using
InTheHand.Net.Sockets;
using
InTheHand.Net.Bluetooth;
using
InTheHand.Net.Forms;
namespace
Svep.QualiTracer.TestController.Plugin
{
/// <summary>
/// Discover and connects to another bluetooth device
/// Sends a file to the device
/// </summary>
///
public class Bluetooth
{
private BluetoothClient bc;
public Bluetooth()
{
try
{
bc =
new BluetoothClient();
}
catch
{
l4n.log.Error("Couldnt load BT-client");
}
BluetoothRadio br = BluetoothRadio.PrimaryRadio;
if(br!=null)
{
br.Mode = RadioMode.Discoverable;
}
else
{
l4n.log.Error("Your device uses an unsupported Bluetooth software stack");
}
sendFile();
}
public void sendFile()
{
l4n.log.Info("sendFile 1");
// use the new select bluetooth device dialog
SelectBluetoothDeviceDialog sbdd =
new SelectBluetoothDeviceDialog();
sbdd.ShowAuthenticated =
true;
sbdd.ShowRemembered =
true;
sbdd.ShowUnknown =
true;
if(sbdd.ShowDialog()==DialogResult.OK)
{
Cursor.Current = Cursors.WaitCursor;
System.Uri uri =
new Uri("obex://" + sbdd.SelectedDevice.DeviceAddress.ToString() + "/" + "test.txt");
//System.Uri uri = new Uri("obex://" + sbdd.SelectedDevice.DeviceAddress.ToString() + "/" + System.IO.Path.GetFileName(ofdFileToBeam.FileName));
ObexWebRequest request =
new ObexWebRequest(uri);
//request.ReadFile(ofdFileToBeam.FileName);
request.ReadFile("c:\\test.txt");
ObexWebResponse response = (ObexWebResponse)request.GetResponse();
l4n.log.Error(response.StatusCode.ToString());
response.Close();
Cursor.Current = Cursors.Default;
}
}
}
}