Die beste Art, Bluetooth-Geräte zu kennen und Dateien von Ihrem PC an ein Bluetooth-Gerät zu senden, ist die Verwendung dieses Codes.
public void ExecuteCommandSync(object command)
{
try
{
// create the ProcessStartInfo using "cmd" as the program to be run,
// and "/c " as the parameters.
// Incidentally, /c tells cmd that we want it to execute the command that follows,
// and then exit.
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
// The following commands are needed to redirect the standard output.
// This means that it will be redirected to the Process.StandardOutput StreamReader.
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
// Get the output into a string
string result = proc.StandardOutput.ReadToEnd();
// Display the command output.
Console.WriteLine(result);
}
catch (Exception objException)
{
// Log the exception
MessageBox.Show(objException.Message);
}
}
Sie können diese Methode aufrufen, als
string command = "fsquirt";
ExecuteCommandSync(command);
So BluetoothFileTransferWizard angezeigt und Sie können verfügbare Gerät wählen und Datei senden für dieses Gerät senden. Wenn Sie nicht auf diese Weise arbeiten möchten, versuchen Sie 32feet.net.uk. Das war großartig für die Bluetooth-Entwicklung für C# und VB.NET.
Außerdem habe ich 32Feet unter Windows 10 versucht und bekomme "32feet.NET unterstützt nicht den Bluetooth-Stack auf diesem Gerät. " Ich habe das Problem gemeldet, aber es sieht so aus, als ob das Projekt in ein paar Jahren nicht aktualisiert wurde ... – LawMan
@LawMan Ich hatte ein ähnliches Problem mit Windows 10. Die Ursache war, dass Bluetooth ausgeschaltet war. –
@Juozas Kontvainis Das war das erste, was ich überprüft habe. Obwohl mein Code das Gerät koppeln würde, wenn es nicht gepaart wäre (oder es zumindest mit ... lol), stellte ich sicher, dass Windows erfolgreich mit dem Gerät gepaart wurde und führte dann meinen Code aus. Außerdem muss 32Feet noch auf mein Problem reagieren. Hier ist der Link zum Thema, wenn jemand interessiert ist. https: //32feet.codeplex.com/workitem/43236 – LawMan