我正在使用 32Feet.net 编写从我的 PC 到三星银河的蓝牙文件传输 以下是代码,我越来越喜欢:
- 内部服务器错误最终
- 在我的移动设备上,我看到文件传输但不完整并显示“远程设备已断开连接”
- 我试图直接从我的电脑发送文件,它成功了,但是使用 C# 它不起作用。
我尝试32Feet.net
了其他一些博客,但无法通过。我读到我应该配对但不知道该怎么做。请帮我解决这个问题。
private void sendFile()
{
SelectBluetoothDeviceDialog dialog = new SelectBluetoothDeviceDialog();
// dialog.ShowAuthenticated = true;
dialog.ShowRemembered = true;
dialog.ShowUnknown = true;
OpenFileDialog ofd = new OpenFileDialog();
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (ofd.ShowDialog() == DialogResult.OK)
{
System.Uri uri = new Uri("obex://" + dialog.SelectedDevice.DeviceAddress + "/" + ofd.FileName);
ObexWebRequest request = new ObexWebRequest(uri);
request.ReadFile(ofd.FileName);
ObexWebResponse response = (ObexWebResponse)request.GetResponse();
MessageBox.Show(response.StatusCode.ToString());
response.Close();
Cursor.Current = Cursors.Default;
}
else
{
MessageBox.Show("File Not Selected");
}
}
else
{
MessageBox.Show("Device Not Selected");
}
}