如何解决无效的 URL:指定的端口无效 32英尺.net
我正在尝试使用 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 举报,一经查实,本站将立刻删除。