ObexWebRequestMethod Property

Gets or sets the method for the request.

Definition

Namespace: InTheHand.Net
Assembly: InTheHand.Net.Obex (in InTheHand.Net.Obex.dll) Version: 4.0.5
C#
public virtual string Method { get; set; }

Property Value

String

Remarks

For Object Exchange the method code is mapped to the equivalent HTTP style method. For example "PUT", "GET" etc. "PUT" is the default value. There is new support for GET as of version 2.5.

To use GET change the Method to "GET" and you must also use scheme "obex-ftp" in the URL instead of the usual "obex" -- unless you know that the default OBEX server you are connecting supports GET.

For a PUT sample see the class documentation. For GET, see below.

Example

VB
' 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 String = "112233445566"
Dim uri As New Uri("obex-ftp://" & addr & "/HelloWorld.txt")
Dim req As New ObexWebRequest(uri)
req.Method = "GET"
Dim rsp As ObexWebResponse = CType(req.GetResponse(), ObexWebResponse)
Console.WriteLine("Response Code: {0} (0x{0:X})", rsp.StatusCode)
Using content As Stream = rsp.GetResponseStream()
   ' Using a StreamReader to read text from the stream...
   Using rdr As New StreamReader(content)
      While True
         Dim line As String = rdr.ReadLine()
         If line Is Nothing Then Exit While
         Console.WriteLine(line)
      End While
   End Using
End Using

See Also