コード例 #1
1
        public static ObexStatusCode SendFile(BluetoothAddress address, string file_path)
        {
            
            Uri uri = new Uri("obex://" + address.ToString() + "/" + file_path);
            ObexWebResponse response;
            try
            {
                ObexWebRequest request = new ObexWebRequest(uri);
                request.ReadFile(file_path);
                response = (ObexWebResponse)request.GetResponse();
                response.Close();
            }
            catch (Exception ex)
            {
                return ObexStatusCode.InternalServerError;
            }

            return response.StatusCode;
        }
コード例 #2
0
ファイル: BTUtils.cs プロジェクト: ArmyOfPirates/PS3BluMote
 public static string FormatBtAddress(string s, BluetoothAddress btA, string format)
 {
     if (s != null && (s.Length == 12 || s.Length == 17))
     {
         try
         {
             return BluetoothAddress.Parse(s).ToString(format).ToLower();
         }
         catch
         {
             DebugLog.write("BTUtils.BtAddress Failed on " + s);
             return "";
         }
     }
     else if (btA != null)
     {
         try
         {
             return btA.ToString(format).ToLower();
         }
         catch
         {
             DebugLog.write("BTUtils.BtAddress Failed with unknown btA");
             return "";
         }
     }
     else
     {
         DebugLog.write("BTUtils.BtAddress : Invalid Parameters");
         return "";
     }
 }
コード例 #3
0
        public static ObexStatusCode SendFile(BluetoothAddress address, string file_path)
        {
            string FileName = file_path.Substring(file_path.LastIndexOf("\\"));
            Uri uri = new Uri("obex://" + address.ToString() + "/" + file_path);

            ObexWebRequest request = new ObexWebRequest(uri);
            request.ReadFile(file_path);
            ObexWebResponse response = (ObexWebResponse)request.GetResponse();
            response.Close();

            return response.StatusCode;
        }
 private void buttonSelectBluetooth_Click(object sender, EventArgs e)//选择远程蓝牙设备
 {
     InTheHand.Windows.Forms.SelectBluetoothDeviceDialog dialog = new InTheHand.Windows.Forms.SelectBluetoothDeviceDialog();
     dialog.ShowRemembered    = true; //显示已经记住的蓝牙设备
     dialog.ShowAuthenticated = true; //显示认证过的蓝牙设备
     dialog.ShowUnknown       = true; //显示位置蓝牙设备
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         sendAddress       = dialog.SelectedDevice.DeviceAddress;//获取选择的远程蓝牙地址
         labelAddress.Text = "地址:" + sendAddress.ToString() + "  设备名:" + dialog.SelectedDevice.DeviceName;
     }
 }
コード例 #5
0
        private void sendfile()
        {
            int index = selected;

            InTheHand.Net.BluetoothAddress address = devices[index].DeviceAddress;
            System.Uri     uri     = new Uri("obex://" + address.ToString() + "/" + "sample.txt"); //Change it to your file name
            ObexWebRequest request = new ObexWebRequest(uri);

            request.ReadFile("c:\\users\\chinmay\\sample.txt"); // Chnage it to your File Path
            ObexWebResponse response = (ObexWebResponse)request.GetResponse();

            response.Close();
        }
コード例 #6
0
ファイル: ObexWebRequest.cs プロジェクト: zhubin-12/32feet
        //
        internal static Uri CreateUrl(string scheme, BluetoothAddress target, string path)
        {
            if (string.IsNullOrEmpty(scheme))
            {
                throw new ArgumentNullException("scheme");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            // (No UriBuilder in NETCF).
            var u0 = new Uri(scheme + "://" + target.ToString("N"));
            var u  = new Uri(u0, path);

            return(u);
        }
コード例 #7
0
        private void sendfile()
        {
            var filepath = FileDialogue();

            foreach (var x in filepath)
            {
                string filename = Path.GetFileName(x);
                int    index    = Selected;
                InTheHand.Net.BluetoothAddress address = this.address_array[index];
                System.Uri     uri     = new Uri("obex://" + address.ToString() + "/" + filename);
                ObexWebRequest request = new ObexWebRequest(uri);
                request.ReadFile(x);
                ObexWebResponse response = (ObexWebResponse)request.GetResponse();
                response.Close();
            }
        }