public class ObexWebRequest : WebRequest
Public Class ObexWebRequest
Inherits WebRequest
public ref class ObexWebRequest : public WebRequest
type ObexWebRequest =
class
inherit WebRequest
end
If you want to transfer a file or other object using the standard service as used by Windows' Wireless Link / Bluetooth File Transfer Wizard, Palm's Beam, Nokia's Send via Infrared, then use the OBEX protocol.
The PUT operation is supported, and there is new support for GET, (see the documentation at the Method property). Changing folders is not supported, nor is getting a folder listing.
In the previous version there were some issue with handling file names that include non-English characters, and connections to some device types failed. Also if the connection to the peer was lost then the request could hang reading forever. See the release note and bugs database for more information.
Dim addr As BluetoothAddress = BluetoothAddress.Parse("002233445566")
Dim path As String = "HelloWorld.txt"
'
Dim req As New ObexWebRequest(addr, path)
req.ReadFile("Hello World.txt")
Dim rsp As ObexWebResponse = CType(req.GetResponse(),ObexWebResponse)
Console.WriteLine("Response Code: {0} (0x{0:X})", rsp.StatusCode)
' The host part of the URI is the device address, e.g. IrDAAddress.ToString(),
' and the file part is the OBEX object name.
Dim addr As BluetoothAddress = ...
Dim addrStr As String = addr.ToString("N")
Dim uri As New Uri("obex://" & addrStr & "/HelloWorld.txt")
'
Dim req As New ObexWebRequest(uri)
req.ReadFile("Hello World.txt")
Dim rsp As ObexWebResponse = CType(req.GetResponse(),ObexWebResponse)
Console.WriteLine("Response Code: {0} (0x{0:X})", rsp.StatusCode)
Dim addr As BluetoothAddress = ...
Dim path As String = "HelloWorld2.txt"
'
Dim req As New ObexWebRequest(addr, path)
Using content As Stream = req.GetRequestStream()
' Using a StreamWriter to write text to the stream...
Using wtr As New StreamWriter(content)
wtr.WriteLine("Hello World GetRequestStream")
wtr.WriteLine("Hello World GetRequestStream 2")
wtr.Flush()
' Set the Length header value
req.ContentLength = content.Length
End Using
' In this case closing the StreamWriter also closed the Stream, but ...
End Using
Dim rsp As ObexWebResponse = CType(req.GetResponse(),ObexWebResponse)
Console.WriteLine("Response Code: {0} (0x{0:X})", rsp.StatusCode)
ObexWebRequest(Uri) | Create a new Obex request with the specified Uri. |
ObexWebRequest(BluetoothAddress, String) | Initialize an instance of this class given a Bluetooth Device Address, and a remote path name. |
ObexWebRequest(Uri, Stream) | [Advanced usage] Create a new Obex request with the specified Uri and the open Stream connection to an OBEX server. |
ObexWebRequest(String, BluetoothAddress, String) | Initialize an instance of this class given a scheme, a Bluetooth Device Address, and a remote path name. |
ContentLength | Gets or sets the Length OBEX header. |
ContentType | Gets or sets the value of the Type OBEX header. |
Headers | Specifies a collection of the name/value pairs that make up the OBEX headers. |
Method | Gets or sets the method for the request. |
Proxy | Not Supported - do not use, this will throw an exception. |
RequestUri | Gets the original Uniform Resource Identifier (URI) of the request. |
Timeout | Gets or sets the time-out value for the GetResponse method. |
BeginGetResponse | Begins a request for a OBEX server response. |
EndGetResponse | Begins a request for a OBEX server response. |
GetRequestStream | Gets a Stream object to use to write request data. |
GetResponse | Returns the OBEX server response. |
GetResponseAsync | |
ReadFile | Reads the contents of the specified file to the request stream. |