问题描述
我正在尝试使用 32feet.net 将 python 文件发送到蓝牙设备,但它引发了此错误。我已经修改了它,所以现在它尝试发送但超时并失败。
System.Net.WebException: Connect Failed. ---> System.Net.sockets.socketException: The requested address is not valid in its context A0AB51BE1948:0000110500001000800000805f9b34fb
at System.Net.sockets.socket.DoConnect(EndPoint endPointSnapshot,SocketAddress socketAddress)
at System.Net.sockets.socket.Connect(EndPoint remoteEP)
at InTheHand.Net.Bluetooth.Msft.socketBluetoothClient.Connect(BluetoothEndPoint remoteEP)
at InTheHand.Net.sockets.BluetoothClient.Connect(BluetoothEndPoint remoteEP)
at InTheHand.Net.ObexWebRequest.Connect()
at InTheHand.Net.ObexWebRequest.GetResponse()
--- End of inner exception stack trace ---
at InTheHand.Net.ObexWebRequest.GetResponse()
at Bluetooth_DualSense.Form1.SendFile(String filetoSend,String destinationPath) in C:\Users\timmy\source\repos\Bluetooth DualSense\Bluetooth DualSense\Form1.cs:line 89
这是我的代码。
public void SendFile(string filetoSend,string destinationPath)
{
string macAddr = "A0AB51BE1948";
var address = BluetoothAddress.Parse(macAddr);
try
{
var obexUri = new Uri("obex://" + address + "/" + destinationPath);
var request = new ObexWebRequest(obexUri);
request.ReadFile(filetoSend);
var response = request.GetResponse() as ObexWebResponse;
response.Close();
}
catch (FileNotFoundException e)
{
textBox1.Text += Environment.NewLine + "||||ERROR||||"+ Environment.NewLine + "No Script Found";
textBox1.Text += Environment.NewLine + "File Created Called: " + e.FileName;
File.Create(e.FileName);
}
catch (Exception ex)
{
textBox1.Text += Environment.NewLine+ex;
}
}
并打电话...
SendFile("FileName.py",Directory.GetCurrentDirectory());
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)